我正在尝试使用Xcode为WWDC奖学金申请在快速的操场中创建一个交互式环境。
运行代码时,即使选择了实时取景,助手编辑器也不会显示任何内容。
import UIKit
import PlaygroundSupport
PlaygroundPage.current.liveView = UIImageView() PlaygroundLiveViewable
var image = UIImage(named: "m.jpg")
let imageView = UIImageView(image: image!)
imageView.frame = CGRect(x: 0, y: 0, width: 60, height: 60)
imageView.backgroundColor = .black
UIView.addSubview(imageView)
答案 0 :(得分:1)
尝试此代码!!
var image = UIImage(named: "m.jpg")
let imageView = UIImageView()
imageView.image = image
imageView.frame = CGRect(x: 0, y: 0, width: 60, height: 60)
imageView.backgroundColor = .black
PlaygroundPage.current.liveView = imageView