I want to make two lines in UIButton. In general, I get it. But I have a case where the second line is longer than the first. And you need to align them in the center. Is it possible The option with spaces is not very pleasant.
1 answer
in the .h file
@property (weak, nonatomic) IBOutlet UIButton *button1; in the .m file
- (void)viewDidLoad { [self.button1.titleLabel setTextAlignment:NSTextAlignmentCenter]; [self.button1 setTitle:@"text\nlong text" forState:0]; } - why outlet in .h? - Max Mikheyenko
- why not? - Rapax
- because encapsulation - Max Mikheyenko
- I doubt that for objective-c the use of this word is appropriate) - Rapax
- if you please explain - Max Mikheyenko
|