
@IBAction func tapbutton() {UIVIEw.animateWithDuration(0.75,delay: 0,options: UIVIEwAnimationoptions.Curvelinear,animations: { self.puppy.Alpha = 1 self.puppy.center.y = 0 },completion: nil) var topoint: CGPoint = CGPointMake(0.0,1.0) var fromPoint : CGPoint = CGPointZero var movement = CABasicAnimation(keyPath: "movement") movement.additive = true movement.fromValue = NSValue(CGPoint: fromPoint) movement.tovalue = NSValue(CGPoint: topoint) movement.duration = 0.3 vIEw.layer.addAnimation(movement,forKey: "move")}解决方法 这样您就可以更改imageVIEw的位置 @IBAction func tapbutton() { UIVIEw.animateWithDuration(0.75,options: .Curvelinear,animations: { // this will change Y position of your imageVIEw center // by 1 every time you press button self.puppy.center.y -= 1 },completion: nil)} 并从您的按钮 *** 作中删除所有其他代码.
总结以上是内存溢出为你收集整理的ios – 如何在Swift中移动图像?全部内容,希望文章能够帮你解决ios – 如何在Swift中移动图像?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)