问题描述
是否可以使用Playground中的animateWithDuration预览为UIView完成的动画?我在UIView初始化之后立即添加了XCPShowView,无论我在时间轴上选择什么位置,它都会显示它处于最终状态。
Is it possible to preview animation done for UIView with animateWithDuration in Playground? I am adding XCPShowView right after initialization of UIView and its shows everything it in a final state no matter what position on a timeline I will choose.
推荐答案
Xcode 7更新: XCPShowView
已被弃用,但你可以看到动画在操场上liveView。还有更多内容即将推出:
Xcode 7 update : XCPShowView
is deprecated but you can see the animation in the playground liveView. And there is more coming soon: Interactive Playgrounds
这是Joseph Chen示例代码的更新。我还将颜色更改为绿色,因为容器默认背景为黑色:
Here is an update to Joseph Chen sample code. I also changed the color to green as the container default background is black :
import UIKit
import XCPlayground
let container = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0))
// XCPShowView("container", view: container) // -> deprecated
let view = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0))
view.backgroundColor = UIColor.greenColor()
container.addSubview(view)
UIView.animateWithDuration(5) {
view.center = CGPoint(x: 75.0, y: 75.0)
}
XCPlaygroundPage.currentPage.liveView=container
这篇关于iOS Playgrounds是否支持UIView动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!