gpt4 book ai didi

ios - 将字符串添加到 uibutton 标题

转载 作者:行者123 更新时间:2023-11-29 03:04:41 25 4
gpt4 key购买 nike

我正在尝试根据数组中的字符串更新按钮的标题,字符串 nextplayername 工作正常,但我正在努力获取显示后的文本。

 [self.shownextbutton setTitle:nextplayerName @"Your Up! " forState:UIControlStateNormal];

基本上我希望按钮标题显示以下“nextplayername string” Your Up!

最佳答案

尝试:

... setTitle:[NSString stringWithFormat:@"%@ You're Up!", nextplayerName] ...

使用格式规范从您想要的内容创建一个字符串。

或者,将字符串附加在一起:

NSString *title = [nextplayerName stringByAppendingString:@" You're Up!"];
... setTitle:title ...

更好,支持本地化:

... setTitle:[NSString stringWithFormat:NSLocalizedString(@"%@ You're Up!", @"Batter up!"), nextplayerName] ...

关于ios - 将字符串添加到 uibutton 标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22916463/

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