gpt4 book ai didi

swift - UISegmented Controller

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

我有一个分段控制程序设置我正在尝试将结果保存到字符串中以供进一步使用

分段控件的代码如下我有问题谁能帮忙?

let genderSelector: UISegmentedControl = {
let genderSelect = UISegmentedControl()
genderSelect.insertSegment(withTitle: "Male", at: 0, animated: true)
genderSelect.insertSegment(withTitle: "Female", at: 1, animated: true)
genderSelect.tintColor = UIColor.black
return genderSelect
}()

最佳答案

像这样尝试:-

let items = ["Male", "Female"]
let customSC = UISegmentedControl(items: items)
customSC.selectedSegmentIndex = 0
let frame = UIScreen.mainScreen().bounds
customSC.frame = //Your Frame
customSC.tintColor = UIColor.blackColor()
customSC.addTarget(self, action: "yourMethod:", forControlEvents: .ValueChanged)
self.view.addSubview(customSC)

关于swift - UISegmented Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45316286/

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