diff options
Diffstat (limited to 'Juick')
-rw-r--r-- | Juick/NavCell.h | 2 | ||||
-rw-r--r-- | Juick/NavCell.m | 27 | ||||
-rw-r--r-- | Juick/RevealPanelViewController.m | 4 |
3 files changed, 15 insertions, 18 deletions
diff --git a/Juick/NavCell.h b/Juick/NavCell.h index 50eec8d..e210636 100644 --- a/Juick/NavCell.h +++ b/Juick/NavCell.h @@ -8,6 +8,8 @@ #import <UIKit/UIKit.h> +#import "UILabel+Utils.h" + @interface NavCell : UITableViewCell @property (strong, nonatomic) IBOutlet UILabel *iconLabel; @property (strong, nonatomic) IBOutlet UILabel *descriptionTextLabel; 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 diff --git a/Juick/RevealPanelViewController.m b/Juick/RevealPanelViewController.m index c39c6cd..9d27608 100644 --- a/Juick/RevealPanelViewController.m +++ b/Juick/RevealPanelViewController.m @@ -64,6 +64,10 @@ static NSString *CellIdentifier = @"NavCell"; return 4; } +- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return 32 + 10*2; // icon size + insets +} + - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NavCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; NSInteger row = indexPath.row; |