我做了一个旋转按钮。但是当按钮旋转时我无法按下它。所以问题是我如何才能使它成为可压缩的"? 我的动画代码是:
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "header"));
因此,如果按下按钮,则没有任何影响。按钮文本动画中没有文字 - 没有!但是按钮保持旋转并且不会对其他场景执行segue。但如果它不是动画,我可以做segue。
答案 0 :(得分:3)
使用动画选项UIViewAnimationOptionAllowUserInteraction。
UIView.animateWithDuration(duration, delay:, options: UIViewAnimationOptions.AllowUserInteraction, animations: , completion: )
答案 1 :(得分:0)
最终代码工作正常,看起来像:
var max: Bool = true
func startAnimation() {
max = !max
let duration: Double = 1
let fullCircle = 2 * M_PI
let upOrDown = (max ? CGFloat(-1 / 16 * fullCircle) : CGFloat(1 / 16 * fullCircle))
let scale: (CGFloat, CGFloat) = (max ? (1.0, 1.0) : (1.3, 1.3))
UIView.animateWithDuration(duration, delay: 0, options: UIViewAnimationOptions.AllowUserInteraction, animations: { () -> Void in
let rotationAnimation = CGAffineTransformMakeRotation(upOrDown)
let scaleAnimation = CGAffineTransformMakeScale(scale)
self.startButton.transform = CGAffineTransformConcat(rotationAnimation, scaleAnimation)
}) { (finished) -> Void in
self.startAnimation()
}
答案 2 :(得分:0)
如果您使用的是UIViewPropertyAnimator
,以下内容也可能会对您有所帮助
let animator = UIViewPropertyAnimator(duration: 2, curve: .easeInOut) {
// animation code
}
animator.isUserInteractionEnabled = true
animator.startAnimation()