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 ?
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

Sometimes closing the playground and restarting Xcode resolves the problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With