Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8.3.2 playground live view rendering doesn't work

This code worked perfectly in previous version of Xcode, but now it doesn't show anything. It is only showing activity indicator that says "Running project"

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

What is wrong with it ?

like image 738
Alexey K Avatar asked Aug 13 '26 23:08

Alexey K


2 Answers

You need to enable the assistant editor to see the results.

View > Assistant Editor > Show Assistant Editor

Also see here: iOS Playground doesn't show UI preview enter image description here

like image 171
Blackvenom Avatar answered Aug 16 '26 17:08

Blackvenom


Sometimes closing the playground and restarting Xcode resolves the problem

like image 40
Iggy Avatar answered Aug 16 '26 15:08

Iggy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!