I have about 10 UIButtons on xib file and want to setText programmatically
Programmatically. To make a multi-line text in UIButton, you insert a new line character ( \n ) wherever you want in button title and set lineBreakMode to byWordWrapping . You can adjust text alignment with . textAlignment .
You can omit UIControlState part and just write like button. setTitle("my text here", forState: . Normal) .
You might want to be more specific next time you ask a question.
You can try assign a different tag for each button in interface builder (or the same tag if thats what you need) and then use the following code
for (int i = 1 ; i<=10;i++) { UIButton *myButton = (UIButton *)[myView viewWithTag:i]; [myButton setTitle:@"my text" forState:UIControlStateNormal]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With