Created
March 5, 2014 20:37
-
-
Save mwhuss/9376071 to your computer and use it in GitHub Desktop.
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
| @interface SNDayView () | |
| @property (nonatomic, strong) UILabel *titleLabel; | |
| @end | |
| @implementation SNDayView | |
| - (id)initWithFrame:(CGRect)frame { | |
| self = [super initWithFrame:frame]; | |
| if (self) { | |
| self.backgroundColor = [UIColor redColor]; | |
| [self addSubview:self.titleLabel]; | |
| } | |
| return self; | |
| } | |
| - (void)layoutSubviews { | |
| [super layoutSubviews]; | |
| if (CGRectGetWidth(self.bounds) < 300) { | |
| self.titleLabel.frame = CGRectZero; | |
| } | |
| else { | |
| self.titleLabel.frame = CGRectZero; | |
| } | |
| } | |
| - (CGSize)sizeThatFits:(CGSize)size { | |
| CGFloat width = 100; | |
| if ([self.titleLabel.text length] > 200) { | |
| width = 200; | |
| } | |
| return CGSizeMake(CGRectGetWidth(width, 100)); | |
| } | |
| #pragma mark - private properties | |
| - (UILabel *)titleLabel { | |
| if (!_titleLabel) { | |
| _titleLabel = [[UILabel alloc] init]; | |
| _titleLabel.textColor = [UIColor blueColor]; | |
| } | |
| return _titleLabel; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment