[英]Add a string to a uibutton title
我正在嘗試根據數組中的字符串更新按鈕的標題,字符串nextplayername可以正常工作,但是在顯示文本后卻難以獲取文本。
[self.shownextbutton setTitle:nextplayerName @"Your Up! " forState:UIControlStateNormal];
基本上,我希望按鈕標題顯示以下“ nextplayername字符串”。
嘗試:
... 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] ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.