gpt4 book ai didi

ios - 如何在每次单击按钮时更改标签文本上的 int 值

转载 作者:行者123 更新时间:2023-11-29 05:54:12 26 4
gpt4 key购买 nike

//这是我还在字符串中使用颜色标签的代码

var cellIndex: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
cellIndex = 1
let s1 = "word \(cellIndex) to \(cellIndex+7)"
let mystring:NSString = "\(s1) recovery phrases" as NSString
var myMutableString = NSMutableAttributedString()
myMutableString = NSMutableAttributedString(string:mystring as String, attributes: [NSAttributedString.Key.font:Font.mediumRegularFont()])
myMutableString.addAttribute(NSAttributedString.Key.foregroundColor, value: Color.darkColor(), range: NSRange(location:0,length:s1.count))
stepBarView.attributedText = myMutableString
}
@IBAction func onNextButtonTap(_ sender: Any) {
// i want to change cellIndex Value every time when i press button.
}

最佳答案

你有2个选择

1 将值替换为replacingOccurrences,但需要考虑该数字可能有多少位数字。2 再次重新创建整个字符串,这样更快、更少工作

关于ios - 如何在每次单击按钮时更改标签文本上的 int 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55327565/

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