ios - 如何在 Playground 的 UIScrollView 中滚动?

标签 ios swift swift-playground

您真的可以在 Playground 的 UIScrollView 中滚动吗?在下面的示例中,我希望能够向下滚动并查看标签。

import UIKit
import XCPlayground

let contentView = UIView(frame: CGRectMake(0, 0, 200, 200))
contentView.backgroundColor = UIColor.yellowColor()

let label = UILabel(frame: CGRectMake(0, 120, 20, 20))
label.text = "a"

contentView.addSubview(label)

let scrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
scrollView.contentSize = CGSize(width: 200, height: 200)
scrollView.addSubview(contentView)
scrollView.flashScrollIndicators()

XCPlaygroundPage.currentPage.liveView = scrollView

最佳答案

编辑:7.3 于 2016 年 3 月 21 日发布到 App Store。最好下载一下there .

正如 Eric 所说,Xcode 7.3 beta 3 中添加了与 playgrounds 的交互。您可以阅读完整的公告 here .由于 Xcode 7.3 仍处于测试阶段,您需要从 here 下载它。 .

关于ios - 如何在 Playground 的 UIScrollView 中滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35935713/

相关文章:

swift - NSScanner 扫描字符串 : intoString: not working in playground

ios - 让ios在进入后台之前等待作业完成

ios - 从 KeychainItem 中检索值

ios - 拉动刷新抛出这个错误

ios - 如何将我的应用程序作为模块包含在 Swift Playground 中?

ios - 修复 Swift Playground 中的低 FPS

ios - UITableViewCell 中的 UICollectionView——动态高度?

ios - GLKView 快照方法 : null return val, 出错

xcode - 调整标签大小以适应文本量 - Swift

ios - AdMob 刷新请求