繁体   English   中英

你如何在 Playground 的 UIScrollView 中滚动?

[英]How do you scroll in a UIScrollView in the 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。 最好在那里下载。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM