Advertisement
Guest User

Untitled

a guest
Feb 8th, 2013
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void) addUnderlineToLabel:(UILabel*) label {
  2.     int lineThickness = 1; //change these to customize the line
  3.     UIColor *lineColor = [UIColor lightGrayColor];
  4.    
  5.     NSString *string = label.text;
  6.     CGSize stringSize = [string sizeWithFont:label.font];
  7.     CGRect buttonFrame = label.frame;
  8.     CGRect labelFrame = CGRectMake(buttonFrame.origin.x + buttonFrame.size.width - stringSize.width, buttonFrame.origin.y + stringSize.height + 1, stringSize.width, lineThickness);
  9.     UILabel *lineLabel = [[UILabel alloc] initWithFrame:labelFrame];
  10.     lineLabel.backgroundColor = lineColor;
  11.  
  12.     [label.superview addSubview:lineLabel];
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement