简体   繁体   English

在ScrollView Xcode Swift内部添加标签

[英]Add labels inside of ScrollView Xcode Swift

I want to display labels and buttons inside a Scrollview. 我想在Scrollview中显示标签和按钮。 Can anybody tell me how this is done? 谁能告诉我这是怎么做的?

@IBOutlet weak var PeopleView: UIScrollView!

 var button = UIButton.buttonWithType(UIButtonType.System) as UIButton
     button.frame = CGRectMake("INSIDE SCROLL.VIEW", "INSIDE SCROLL.VIEW", 183, 21)
     button.backgroundColor = UIColor.greenColor()
     button.setTitle("Button", forState: UIControlState.Normal)
     button.addTarget(self, action: "Action:", forControlEvents: UIControlEvents.TouchUpInside)
     self.view.addSubview(button)

Use this line of code 使用此行代码

self.PeopleView.addSubview(button)

instead of 代替

self.view.addSubview(button)

and make sure you are passing a CGFloat value while giving buttons or labels frame 并确保在给按钮或标签框时传递CGFloat

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

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