【问题标题】:animation not working in xcode 8 playground swift 3动画在 xcode 8 playground swift 3 中不起作用
【发布时间】:2017-01-10 20:01:12
【问题描述】:

我正在尝试使用 swift 3 简单地了解有关 Xcode 8 操场中动画的更多信息。我已经了解到 swift 不再使用 XCPlayground,而是使用“import PlaygroundSupport”。

我无法在助理编辑器中显示任何内容。有谁知道这个问题的解决方法还是只是新 Xcode 8 的一个错误

任何帮助都会很棒。谢谢。

import UIKit

import PlaygroundSupport

let containerView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 375.0, height: 667.0))
PlaygroundPage.current.needsIndefiniteExecution = true
PlaygroundPage.current.liveView =  containerView

let circle = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0))
circle.center = containerView.center
circle.layer.cornerRadius = 25.0

let startingColor = UIColor(red: (253.0/255.0), green: (159.0/255.0), blue: (47.0/255.0), alpha: 1.0)
circle.backgroundColor = startingColor

containerView.addSubview(circle);

let rectangle = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0))
rectangle.center = containerView.center
rectangle.layer.cornerRadius = 5.0

rectangle.backgroundColor = UIColor.white

containerView.addSubview(rectangle)

UIView.animate(withDuration: 2.0, animations: { () -> Void in
    let endingColor = UIColor(red: (255.0/255.0), green: (61.0/255.0), blue: (24.0/255.0), alpha: 1.0)
    circle.backgroundColor = endingColor

    let scaleTransform = CGAffineTransform(scaleX: 5.0, y: 5.0)

    circle.transform = scaleTransform

    let rotationTransform = CGAffineTransform(rotationAngle: 3.14)

    rectangle.transform = rotationTransform
})

【问题讨论】:

    标签: animation swift3 xcode8 ios10


    【解决方案1】:

    打开助手编辑器以查看动画的实时视图,如article 中所述,您将以此为基础

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-01
      • 2017-01-20
      • 1970-01-01
      • 2017-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多