解决即时取景问题

时间:2018-12-23 08:19:18

标签: ios swift

我正在尝试使用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)

1 个答案:

答案 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