2012-07-18 122 views
2

如何設置UIButton如何設置標題上的UIButton

topYellowButton2 = [UIButton buttonWithType:UIButtonTypeCustom]; 
topYellowButton2.frame = CGRectMake(80, 0, 90, 20); 

[topYellowButton2 setTitleColor:[UIColor colorWithRed:0.0 green:0.6 blue:1.0 alpha:1.0] forState:UIControlStateNormal]; 

回答

0
[topYellowButton2 setTitle:@"My Title" forState:UIControlStateNormal]; 
+0

你忘了';'! ;) – Martin 2012-07-18 07:30:40

0

文本只需添加這一行:

[topYellowButton2 setTitle:@"my button" forState:UIControlStateNormal]; 
2

嘗試用於本屆

topYellowButton2=[UIButton buttonWithType:UIButtonTypeCustom]; 
topYellowButton2.frame=CGRectMake(80, 0, 90, 20); 
[topYellowButton2 setTitle:@"Your Title" forState:UIControlStateNormal]; 
1

設置標題正常和突出顯示

[topYellowButton2 setTitle:@"Button Title" forControlState:UIControlStateNormal]; 
[topYellowButton2 setTitle:@"Button Title" forControlState:UIControlStateHighlighted];