let shake = CAKeyframeAnimation(keyPath: "position.x") shake.values = [0,20,-20,-15,15,-5,5,0] shake.keyTimes = [0,1/10.0,3/10.0,5/10.0,6/10.0,7/10.0,8/10.0,9/10.0,1] shake.duration = 0.4 shake.additive = true circlesContainer.layer.addAnimation(shake,forKey: "shakeYourBooty")
通过结合UIPushBehavior和UIAttachmentBehavior这样的d簧效果
if origCirclesContainerCenter == nil { origCirclesContainerCenter = circlesContainer.center } shake = UIDynamicAnimator(referenceVIEw: self.vIEw) let push = UIPushBehavior(items: [circlesContainer],mode: UIPushBehaviorMode.Continuous) push.pushDirection = CGVectorMake(100.0,0.0) print(origCirclesContainerCenter) let attachement = UIAttachmentBehavior(item: circlesContainer,attachedToAnchor:origCirclesContainerCenter!) attachement.frequency = 3.0 attachement.damPing = 0.5 shake.addBehavior(attachement) shake.addBehavior(push)
问题是附件行为似乎不起作用,因为视图在被推动后不会d回到原始位置.动画实际上将视图位置推到右侧100点. origCirclesContainerCenter在每次通话时都是相同的.任何的想法?
解决方法 我将推送行为模式更改为UIPushBehaviorMode.Instantaneous以解决问题. 总结以上是内存溢出为你收集整理的ios – UIDynamicAnimator具有d簧效果全部内容,希望文章能够帮你解决ios – UIDynamicAnimator具有d簧效果所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)