显然,这个问题只发生在iOS 11.2.6上.我更新了我的设备,现在无法重现该问题.任何人都可以确认或了解它如何在iOS 11.2.6上运行?
import UIKitclass MyVIEwController : UIVIEwController { let animatedVIEw = UIVIEw() overrIDe func loadVIEw() { let vIEw = UIVIEw() vIEw.backgroundcolor = .white // Add a button let button = UIbutton(type: .system) button.frame = CGRect(x: 150,y: 200,wIDth: 200,height: 50) button.setTitle("Animate",for: .normal) button.addTarget(self,action: #selector(tap),for: .touchUpInsIDe) // Set color and frame of the vIEw,that is animated. animatedVIEw.backgroundcolor = UIcolor.blue animatedVIEw.frame = CGRect(x: 50,y: 50,wIDth: 50,height: 50) // Add the vIEws to the vIEw hIErarchy vIEw.addSubvIEw(animatedVIEw) vIEw.addSubvIEw(button) self.vIEw = vIEw } /// On Tap create an animation,that changes the position of the animated vIEw. @objc func tap() { let originalY = animatedVIEw.layer.position.y let animation = CABasicAnimation(keyPath: "position.y") animation.fromValue = originalY animation.tovalue = 300.0 animation.duration = 1.0 animatedVIEw.layer.add(animation,forKey: "positionAnimation") }}
Can you try this code with iOS 11.2.9,I have tested your code and it’s working fine.
// MARK: Animationspublic extension CALayer { var ani: CAAnimation { let startPointAnim = CABasicAnimation(keyPath: #keyPath(CAGradIEntLayer.startPoint)) startPointAnim.fromValue = CGPoint(x: 0,y: 0.0) startPointAnim.tovalue = CGPoint(x:0,y: 300) let endPointAnim = CABasicAnimation(keyPath: #keyPath(CAGradIEntLayer.endPoint)) endPointAnim.fromValue = CGPoint(x: 0,y: 0) endPointAnim.tovalue = CGPoint(x:2,y: 300) let animgroup = CAAnimationGroup() animgroup.animations = [startPointAnim,endPointAnim] animgroup.duration = 1.0 animgroup.timingFunction = camediatimingFunction(name: kcamediatimingFunctionEaseIn) return animgroup } func playAnimation(_ anim: SkeletonLayerAnimation,key: String) { recursiveSearch(inArray: skeletonSublayers,leafBlock: { add(anim(self),forKey: key) }) { .playAnimation(anim,key: key) } } func stopAnimation(forKey key: String) { recursiveSearch(inArray: skeletonSublayers,leafBlock: { removeAnimation(forKey: key) }) { .stopAnimation(forKey: key) } }}总结
以上是内存溢出为你收集整理的swift – 动画滞后于设备,但不在模拟器中全部内容,希望文章能够帮你解决swift – 动画滞后于设备,但不在模拟器中所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)