Swift游乐场的动画问题

问题描述 投票:0回答:1

我是一个完全陌生的动画与swift和我开始这个概念通过使用游乐场这里是我的代码下面我没有 "想法 "为什么它不工作。

import UIKit
import PlaygroundSupport

let liveViewFrame = CGRect(x: 0, y: 0, width: 500, height: 500)
let liveView = UIView(frame: liveViewFrame)
liveView.backgroundColor = .white
PlaygroundPage.current.liveView = liveView

let smallFrame = CGRect(x: 0, y: 0, width: 100, height: 100)
let square = UIView(frame: smallFrame)
square.backgroundColor = .purple
liveView.addSubview(square)

UIView.animate(withDuration: 3.0) {
    liveView.backgroundColor = .blue
}
swift animation uikit swift-playground
1个回答
0
投票

这段代码工作正常 enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.