swift playground 支持 UIKit 吗? [英] Does swift playground support UIKit?

查看:43
本文介绍了swift playground 支持 UIKit 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在操场上创建一个 UILabel 但失败了.Playground 目前只支持 OS X 开发吗?

I tried to create a UILabel in playground but failed. Does playground only support OS X development for now?

推荐答案

是的,确实如此!

文件:新建 >文件... >iOS >来源 >游乐场

File: New > File... > iOS > Source > Playground

import UIKit
let lbl = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 100))
lbl.text = "Hello StackOverflow!"

然后,保存文件.(或手动运行它.)这将触发 Playground 解释 UI 相关的东西.此时,UILabel"这个词出现了.应出现在右侧.

Then, save the file. (Or manually run it.) This will trigger the Playground to interpret UI related things. At this point, the word "UILabel" should appear on the right-hand side.

现在,要实际查看您所做的工作,您必须单击快速查看"按钮.右侧的眼睛,或在助理编辑器"中打开它的白色圆圈:

Now, to actually view what you've done, you've got to click on the "Quick View" eye on the right, or the white circle to open it in Assistant Editor:

这是 UIImage 工作等的一些基本内容的屏幕截图.

Here's a screenshot of some basic things with UIImage working, etc.

(当前 CGRect 语法的小文本更新——但是,屏幕截图仍然显示旧语法.)

( minor text update to current CGRect syntax -- But, screenshots still show old syntax.)

这篇关于swift playground 支持 UIKit 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆