summaryrefslogtreecommitdiff
path: root/Juick/NavCell.m
blob: 8cd460a1fa1818b4a0e2fe09a0a2abfe3f4251be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
//  NavCell.m
//  Juick
//
//  Created by Vitaly on 17.12.13.
//  Copyright (c) 2013 com.juick. All rights reserved.
//

#import "NavCell.h"

@interface NavCell ()

@property (nonatomic, assign) BOOL didSetupConstraints;

@end

@implementation NavCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        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)layoutSubviews {
    [super layoutSubviews];
    
    CGRect iconRect = [UILabel sizeForLabel:self.iconLabel width:36.0f];
    self.iconLabel.frame = CGRectMake(10, 10, iconRect.size.width, iconRect.size.height);
    float textHeight = [UILabel sizeForLabel:self.descriptionTextLabel width:self.contentView.bounds.size.width].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