Xcode 8.3.2游乐场实时视图渲染不起作用

时间:2017-04-27 09:44:32

标签: ios swift xcode swift-playground

此代码在以前版本的Xcode中运行良好,但现在它没有显示任何内容。它只显示活动指示符,表示"正在运行项目"

import UIKit
import PlaygroundSupport

let container = UIView()
container.frame.size = CGSize(width: 215.0, height: 215.0)

var view = UIView()
view.frame.size = CGSize(width: 185.0, height: 185.0)
view.center = container.center
view.layer.cornerRadius = view.frame.size.height/2
view.backgroundColor = UIColor.white

container.addSubview(view)

let scaleAnimation = CABasicAnimation(keyPath: "transform.scale")
scaleAnimation.fromValue = CGFloat(0.6)
scaleAnimation.toValue = CGFloat(1.15)
scaleAnimation.timingFunction = CAMediaTimingFunction(name:    kCAMediaTimingFunctionEaseOut)
scaleAnimation.isRemovedOnCompletion = false

let opacityAnimation = CABasicAnimation(keyPath: "opacity")
opacityAnimation.fromValue = CGFloat(0.0)
opacityAnimation.toValue = CGFloat(0.1)
opacityAnimation.duration = 1
opacityAnimation.isRemovedOnCompletion = false
opacityAnimation.autoreverses = true;


let circleAnimations: CAAnimationGroup = CAAnimationGroup()
circleAnimations.duration = 2
circleAnimations.repeatCount = HUGE;
circleAnimations.animations = [scaleAnimation, opacityAnimation];

view.layer .add(circleAnimations, forKey: "circleAnimations")

PlaygroundPage.current.liveView = container
PlaygroundPage.current.needsIndefiniteExecution = true

它出了什么问题?

2 个答案:

答案 0 :(得分:11)

您需要启用助理编辑器才能查看结果。

查看>助理编辑>显示助理编辑器

另见: iOS Playground doesn't show UI preview enter image description here

答案 1 :(得分:0)

有时关闭游乐场并重新启动Xcode可以解决问题