It is possible to set number of lines of a label by going to the Attribute Inspector and assigning value 0 to the lines attribute.
In case of Text Field we can use Text View but if we are using UIButton then there is no option for the multiple lines in attribute inspector.
Suppose we are using UIButton and we want that the text should display in multiple lines so we can do this by using following code. In below code myUIButtonOutlet is the UIButton Outlet.
myUIButtonOutlet.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
myUIButtonOutlet.titleLabel.textAlignment = NSTextAlignmentCenter; // if you want that the text should align in center
[myUIButtonOutlet setTitle: @"55\nPosts" forState: UIControlStateNormal];
Here for line break we used “\n” . 55 will come in first line and Posts will come in second line.
0 Comment(s)