2

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 ?

Alexey K
  • 6,537
  • 18
  • 60
  • 118

2 Answers2

11

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

Community
  • 1
  • 1
Blackvenom
  • 667
  • 6
  • 13
1

Sometimes closing the playground and restarting Xcode resolves the problem

Iggy
  • 8,463
  • 3
  • 31
  • 21