Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

swift - 如何在Swift 5中更改按钮的文本/标题?(How to change button text/title in swift 5?)

hi i'm trying to change the button's title/text with swift 5.i found some codes on StackOverflow but none of them works.

(您好,我想用swift 5更改按钮的标题/文本。我在StackOverflow上找到了一些代码,但是它们都不起作用。)

this is my code:

(这是我的代码:)

func updateUI(){
    storyLabel.text = storyBrain.getStory()
    choice1Button.setTitle("Button Title", for: .normal)
}

but the button's title doesn't change.

(但按钮的标题不变。)

I'm pretty sure that button is connected to my controller because I can change its color

(我很确定该按钮已连接到控制器,因为我可以更改其颜色)

  ask by couri_g translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...