Reputation: 601
How to set text on 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];
Upvotes: 2
Views: 147
Reputation: 1336
Simply add this line:
[topYellowButton2 setTitle:@"my button" forState:UIControlStateNormal];
Upvotes: 0
Reputation: 385
Set Title for both Normal and Highlighted
[topYellowButton2 setTitle:@"Button Title" forControlState:UIControlStateNormal];
[topYellowButton2 setTitle:@"Button Title" forControlState:UIControlStateHighlighted];
Upvotes: 1
Reputation: 10398
[topYellowButton2 setTitle:@"My Title" forState:UIControlStateNormal];
Upvotes: 0
Reputation: 6152
Try this
topYellowButton2=[UIButton buttonWithType:UIButtonTypeCustom];
topYellowButton2.frame=CGRectMake(80, 0, 90, 20);
[topYellowButton2 setTitle:@"Your Title" forState:UIControlStateNormal];
Upvotes: 2