Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Set Dynamic Size of button according to the Title text

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.60k
    Comment on it

    if you want to change the size of UIButton according to the title text then use the following function--

    -(void)setDynamicSizeOfButton:(UIButton *)button andSize:(CGFloat)Size {
        CGSize size = [button.titleLabel.text sizeWithAttributes:
                       @{NSFontAttributeName: [UIFont systemFontOfSize:Size]}];
    
        button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y, ceilf(size.width+13),ceilf(size.height));
    }
    

    Here Size refer to the Font Size of title.

 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: