Created
February 29, 2012 02:01
-
-
Save ehuynh/1936946 to your computer and use it in GitHub Desktop.
Resizes the height of a UILabel so that the contain appears vertically align.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface UILabel (VerticalAlign) | |
- (void)alignTop; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UILabel+VerticalAlign.h" | |
@implementation UILabel (VerticalAlign) | |
- (void)alignTop | |
{ | |
CGSize descriptionSize = [self.text sizeWithFont:self.font | |
constrainedToSize:self.frame.size | |
lineBreakMode:self.lineBreakMode]; | |
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, descriptionSize.height); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment