gpt4 book ai didi

ios - 更改 UIPicker 颜色

转载 作者:搜寻专家 更新时间:2023-10-30 22:01:44 24 4
gpt4 key购买 nike

如何更改选择器的颜色?

我不想更改字体或文本。我的选择器已填充并完全按照我想要的方式工作,我想做的是将颜色从黑色更改为我的自定义白色。

最佳答案

看看:http://makeapppie.com/tag/uipickerview-in-swift/

如果你想改变你可以实现的每个元素的标题颜色:

func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let titleData = pickerData[row]
var myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 15.0)!,NSForegroundColorAttributeName:UIColor.whiteColor()])
return myTitle
}

swift 3:

func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let titleData = pickerData[row]
let myTitle = NSAttributedString(string: titleData!, attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 15.0)!,NSForegroundColorAttributeName:UIColor.white])
return myTitle
}

关于ios - 更改 UIPicker 颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29243564/

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