以编程方式快速更改UIButton的文本 [英] Changing text of UIButton programmatically swift
本文介绍了以编程方式快速更改UIButton的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里简单的问题。我有一个UIButton,currencySelector,我想以编程方式更改文本。这就是我所拥有的:
Simple question here. I have a UIButton, currencySelector, and I want to programmatically change the text. Here's what I have:
currencySelector.text = "foobar"
Xcode给出了错误预期声明。我做错了什么,如何更改按钮的文本?
Xcode gives me the error "Expected Declaration". What am I doing wrong, and how can I make the button's text change?
推荐答案
在Swift 3中:
button.setTitle("Button Title",for: .normal)
否则:
button.setTitle("Button Title", forState: UIControlState.Normal)
这篇关于以编程方式快速更改UIButton的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文