簡體   English   中英

UIButton的標題標簽未顯示

[英]Title Label not showing for UIButton

我試圖通過這樣的數組設置UIButton文本:

// Set User Name
NSString *user = entry[@"user"][@"full_name"];
[cell.nameLabel.titleLabel setText:user];

但是,加載時應用程序上沒有文本。 文本將被返回並存儲在數組中。 這是我對Button的自定義:

// Name
self.nameLabel = [[UIButton alloc] initWithFrame:CGRectMake(58, 6, 192, 25)];
[self.nameLabel.titleLabel setFont:[UIFont fontWithName:@"Helvetica-Regular" size:12.0]];
self.nameLabel.titleLabel.textColor = [UIColor colorWithRed:(38.0/255.0) green:(120.0/255.0) blue:(172.0/255.0) alpha:1.0];
[self.contentView addSubview:self.nameLabel];
[self.nameLabel setTitle:user forState:UIControlStateNormal];

我認為您已經找到了問題的答案。 但是,如果您正在尋找不同的東西,請嘗試以下操作: 是否可以通過編程方式更新UIButton標題/文本?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM