Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Increase Label height according to Text in iPhone

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 270
    Comment on it

    On top header area

    #define kDefaultCellFont [UIFont fontWithName:@"HoboStd" size:10.0f]
    
    NSString *text = @"This is a simple example of the versatility of blocks, but the standard frameworks are chock-full of other use cases. NSArray lets you sort elements with a block via the sortedArrayUsingComparator: method, and UIView uses a block to define the final state of an animation via the animateWithDuration:animations: method. Blocks are also a powerful tool for concurrent programming."
    
     NSString *trimmedContent = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    constraintSize = CGSizeMake(<WIDTH of Label>, MAXFLOAT);
    
    //You will need to define kDefaultCellFont
    CGSize labelSize = [trimmedContent sizeWithFont:kDefaultCellFont
                        constrainedToSize:constraintSize
                            lineBreakMode:NSLineBreakByWordWrapping];
    
    
    labelSize.height = ceil(labelSize.height)+5;
    

 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: