public func performAction(action: PreloaderAction){ let highOpacity = CABasicAnimation.init(keyPath: "opacity") let mIDdleOpacity = CABasicAnimation.init(keyPath: "opacity") let lowOpacity = CABasicAnimation.init(keyPath: "opacity") if action == .PreloaderActionNone { self.thirdShape.removeAllAnimations() self.firstShape.opacity = 0.3; self.secondShape.opacity = 0.5 self.thirdShape.opacity = 1.0 } else if action == .PreloaderActionFailure { UIVIEw.animateWithDuration(2,animations: { self.thirdShape.strokecolor = UIcolor.redcolor().CGcolor }) {(completed : Bool) in self.thirdShape.strokecolor = self.ringcolor.CGcolor } } if action == .PreloaderActionStart { highOpacity.fromValue = 0.0 highOpacity.tovalue = 1.0 highOpacity.duration = animationDuration highOpacity.autoreverses = true highOpacity.repeatCount = .infinity self.secondShape.addAnimation(highOpacity,forKey: "highOpacity") mIDdleOpacity.fromValue = 0.0 mIDdleOpacity.tovalue = 1.0 mIDdleOpacity.duration = animationDuration mIDdleOpacity.autoreverses = true mIDdleOpacity.repeatCount = .infinity mIDdleOpacity.beginTime = CACurrentMediaTime() + 0.33 self.firstShape.addAnimation(mIDdleOpacity,forKey: "mIDdleOpacity") lowOpacity.fromValue = 0.0 lowOpacity.tovalue = 1.0 lowOpacity.duration = animationDuration lowOpacity.autoreverses = true lowOpacity.beginTime = CACurrentMediaTime() + 0.66 lowOpacity.repeatCount = .infinity self.thirdShape.addAnimation(lowOpacity,forKey: "lowOpacity") }}
这是我的游乐场文件
和项目导航器中的游乐场
动画在设备上运行良好,但是当我使用游乐场动画时无法正常工作.
解决方法 Xcode 7,Swift 2加
import XCPlayground
在游乐场的顶部,然后使用
XCPlaygroundPage.currentPage.liveVIEw = vIEw
在Playground的底部,其中视图是您要渲染的视图.
您还必须打开“助理编辑器”(在“视图”菜单中)才能看到当前的实时视图.
此外,如果您正在使用异步 *** 作,则必须包括
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
为了在游乐场中使用它们.
Xcode 8,Swift 3
import PlaygroundSupportPlaygroundPage.current.needsIndefiniteExecution = truePlaygroundPage.current.liveVIEw = vIEw总结
以上是内存溢出为你收集整理的动画不在ios游乐场工作全部内容,希望文章能够帮你解决动画不在ios游乐场工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)