ios - 使用 Swift 自动布局动画 UIButton

标签 ios swift animation uiview autolayout

Hello Community 我只想为 UIView 和 UIButton 制作动画。但它真的不适合我。

 self.introConstraints.constant = self.view.frame.width
    self.view.needsUpdateConstraints()
    UIView.animateWithDuration(0.6){
        self.view.layoutIfNeeded()
    }

这就是我的代码的样子。

最佳答案

=> 试试这个:-

UIView.animateWithDuration(0.6 , 动画: { self.button.transform = CGAffineTransformMakeScale(0.6, 0.6)

},

completion: { 

    UIView.animateWithDuration(0.6){

        self.button.transform = CGAffineTransformIdentity
    }
})

=> 如果你想用 Spring 动画获得更多的弹跳效果。:-

=>尝试下面的代码:

@IBOutlet 弱变量按钮:UIButton!

@IBAction func animateButton(sender: AnyObject) {

    button.transform = CGAffineTransformMakeScale(0.6, 0.6)

   UIView.animateWithDuration(2.0,

   delay: 0,
   usingSpringWithDamping: CGFloat(0.20),

   initialSpringVelocity: CGFloat(6.0),

   options: UIViewAnimationOptions.AllowUserInteraction,

   animations: {

        self.button.transform = CGAffineTransformIdentity
   },
      completion: { Void in()  }
 )
}

关于ios - 使用 Swift 自动布局动画 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34618161/

相关文章:

ios - 使用 UIDocumentPickerViewController(文档类型 :) in swift

css - 使用 CSS 无限循环动画图像

javascript - 页面切换之间的动画功能

ios - 如何使 NSOperationQueue 序列化?

ios - 在 Swift 中,如何强制键盘在程序启动时打开?

ios - tableview平滑滚动最佳实践swift

Swift - 代码重用

regex - 枚举字符串中的匹配项

ios - 沿着贝塞尔路径拖动 UIView

ios - 不会将图像传递到目标 ViewController