ios - Xcode 8.3.2 Playground 实时 View 渲染不起作用

标签 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

有什么问题吗?

最佳答案

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

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

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

关于ios - Xcode 8.3.2 Playground 实时 View 渲染不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43654195/

相关文章:

ios - 使用自定义框架时出现"Unknown class BarChartView in Interface Builder file"错误

swift - Xcode 9.2 没有显示 Swift 4.1

ios - 在 SpriteKit Swift 3 中停止/暂停设置为永远重复的声音

ios - 在 ObjC 中工作,而不是在 swift 中工作。我在 swift 中使用 JSON 解析有什么问题

ios - 从ios中的视频中获取所有帧

swift - 使用 Swift 实现 NSTableViewRowAction

ios - 没有匹配函数调用 'dot' 和 'reflect'

swift - 无法在 Xcode Playground 中为 Swift 导入 TensorFlow

ios - 向场景中添加一个随机的 SKSpriteNode

ios - 如何在 Xcode 的 Storyboard中显示状态栏