gpt4 book ai didi

ios - 在 ScrollView Xcode Swift 中添加标签

转载 作者:行者123 更新时间:2023-11-29 02:29:41 25 4
gpt4 key购买 nike

我想在 ScrollView 中显示标签和按钮。谁能告诉我这是怎么做到的?

@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)

最佳答案

使用这行代码

self.PeopleView.addSubview(button)

代替

self.view.addSubview(button)

并确保在给按钮或标签框架时传递一个 CGFloat

关于ios - 在 ScrollView Xcode Swift 中添加标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27062600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com