diff options
Diffstat (limited to 'Juick/NavCell.m')
-rw-r--r-- | Juick/NavCell.m | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/Juick/NavCell.m b/Juick/NavCell.m index 0b16e43..594b23b 100644 --- a/Juick/NavCell.m +++ b/Juick/NavCell.m @@ -23,31 +23,22 @@ self.backgroundColor = [UIColor blackColor]; self.iconLabel = [[UILabel alloc] initWithFrame:CGRectZero]; self.descriptionTextLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + self.descriptionTextLabel.numberOfLines = 1; + self.descriptionTextLabel.textAlignment = NSTextAlignmentLeft; [self.contentView addSubview:self.iconLabel]; [self.contentView addSubview:self.descriptionTextLabel]; } return self; } -- (void)updateConstraints { - [super updateConstraints]; +- (void)layoutSubviews { + [super layoutSubviews]; - if (self.didSetupConstraints) return; - [self.iconLabel makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.contentView.left).with.offset(20.f); - make.top.equalTo(self.contentView.top).with.offset(10.f); - make.width.equalTo(@36); - make.height.equalTo(@36); - - }]; - - [self.descriptionTextLabel makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.iconLabel.right).with.offset(10.f); - make.top.equalTo(self.contentView.top).with.offset(15.f); - make.right.equalTo(self.contentView.right).with.offset(-20.f); - }]; - - self.didSetupConstraints = YES; + CGRect iconRect = [UILabel sizeForLabel:self.iconLabel width:320.0f]; + self.iconLabel.frame = CGRectMake(10, 10, iconRect.size.width, iconRect.size.height); + float textHeight = [UILabel sizeForLabel:self.descriptionTextLabel width:320.0f].size.height; + self.descriptionTextLabel.frame = CGRectMake(10 + self.iconLabel.frame.size.width + 10, 10 + (iconRect.size.height - textHeight) / 2, + self.contentView.bounds.size.width - self.iconLabel.frame.size.width - 10*3, textHeight); } @end |