なんとかするから、なんとかなる

エンジニア関係のことを書きます

iOS How to detect an user interacion while animating

Introduction

This article shows how to detect an user interaction while animating on UIView or UIbutton or etc.

Solution

Set the ".allowUserIntercation" properties in option at UIView.animate method.

UIView.animate(withDuration: 1.0, 
    delay: 0,
    options: [.allowUserInteraction],
    animations: {
    self.view.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
}, completion: nil)    }

Reference URL