Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Line Break on UIButton Text

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 640
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: