From 552680443dea2ea5e3ce64d03dc4b6d2e39a7226 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 1 Feb 2014 20:17:59 +0400 Subject: Manual layout in reveal panel, deployment target now ios 5.1 --- Juick/NavCell.h | 2 ++ Juick/NavCell.m | 27 +++++++++------------------ Juick/RevealPanelViewController.m | 4 ++++ 3 files changed, 15 insertions(+), 18 deletions(-) (limited to 'Juick') 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 +#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; -- cgit v1.2.3