Posted By

rabc on 07/08/11


Tagged

align vertical UILabel


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Tintenklecks
cnathan
dvel


UILabel Vertical Align


 / Published in: Objective C
 

URL: http://stackoverflow.com/questions/1054558/uilabel-vertical-alignment

  1. CGSize maximumSize = CGSizeMake(300, 9999);
  2. NSString *dateString = @"The date today is January 1st, 1999";
  3. UIFont *dateFont = [UIFont fontWithName:@"Helvetica" size:14];
  4. CGSize dateStringSize = [dateString sizeWithFont:dateFont
  5. constrainedToSize:maximumSize
  6. lineBreakMode:self.dateLabel.lineBreakMode];
  7.  
  8. CGRect dateFrame = CGRectMake(10, 10, 300, dateStringSize.height);
  9.  
  10. self.dateLabel.frame = dateFrame;

Report this snippet  

You need to login to post a comment.