Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 080aca8584
Fetching contributors…

Cannot retrieve contributors at this time

72 lines (49 sloc) 1.281 kb
//
// ZYTopAlignedLabel.m
// Zerously Toolkit.
//
// Created by Mariano Abdala on 11/3/11.
// Copyright (c) 2011 Zerously.com. All rights reserved.
//
#import "ZYTopAlignedLabel.h"
@interface ZYTopAlignedLabel ()
@property (nonatomic, unsafe_unretained) CGRect originalFrame;
@end
@implementation ZYTopAlignedLabel
@synthesize originalFrame = _originalFrame;
#pragma mark - Hierarchy
#pragma mark NSObject
- (id)initWithFrame:(CGRect)frame {
self =
[super initWithFrame:frame];
if (self != nil) {
self.originalFrame = frame;
}
return self;
}
#pragma mark UIView
- (void)awakeFromNib {
self.originalFrame =
self.frame;
}
#pragma mark UILabel
- (void)setText:(NSString *)text {
[super setText:text];
self.frame =
self.originalFrame;
CGSize newSize =
[self.text sizeWithFont:self.font
constrainedToSize:self.frame.size
lineBreakMode:self.lineBreakMode];
CGRect newFrame =
CGRectMake(self.frame.origin.x,
self.frame.origin.y,
self.frame.size.width,
newSize.height);
self.frame =
newFrame;
}
#pragma mark - Self
#pragma mark ZYTopAlignedLabel
#pragma mark ZYTopAlignedLabel ()
@end
Jump to Line
Something went wrong with that request. Please try again.