【发布时间】:2019-03-24 19:18:07
【问题描述】:
//这是我在字符串中也使用颜色标签的代码
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.
}
【问题讨论】: