SelectAreaTableCell.m 4.16 KB
Newer Older
admin's avatar
admin committed
1 2 3 4 5 6 7 8 9 10 11 12
//
//  SelectAreaTableCell.m
//  redstar
//
//  Created by admin on 15/12/15.
//  Copyright © 2015年 ZWF. All rights reserved.
//

#import "SelectAreaTableCell.h"

@implementation SelectAreaTableCell

admin's avatar
admin committed
13 14 15 16 17
- (CheckBoxButton *)checkBoxButton
{
    if (!_checkBoxButton) {
        _checkBoxButton = [[CheckBoxButton alloc] init];
        [_checkBoxButton setTitleColor:kLightBlack forState:UIControlStateNormal];
admin's avatar
admin committed
18
//        [_checkBoxButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected];
admin's avatar
admin committed
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 44 45 46
        _checkBoxButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
        _checkBoxButton.translatesAutoresizingMaskIntoConstraints = NO;
        [_checkBoxButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal];
        [_checkBoxButton setImage:[UIImage imageNamed:@"check_box"] forState:UIControlStateSelected];
        _checkBoxButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
        _checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
        _checkBoxButton.imageView.contentMode = UIViewContentModeRight;
        _checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft;
        [self.contentView addSubview:_checkBoxButton];
        
        // 顶端
        NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
        [self.contentView addConstraint:titleTop];
        
        // 左边
        NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self.contentView addConstraint:titleLeft];
        
        
        NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:34];
        [self.contentView addConstraint:titleHeight];
        
        // 高度
        NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
        [self.contentView addConstraint:titleBottom];
    }
    return _checkBoxButton;
}
admin's avatar
admin committed
47

admin's avatar
admin committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

- (UIImageView *)iconImageView
{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] init];
        _iconImageView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.contentView addSubview:_iconImageView];
        
        // 顶端
        NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:23];
        [self.contentView addConstraint:titleTop];
        
        // 左边
        NSLayoutConstraint *titleWidth = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:13];
        [self.contentView addConstraint:titleWidth];
        
        // 右边
        NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self.contentView addConstraint:titleRight];
        
        // 高度
        NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:8];
        [self.contentView addConstraint:titleBottom];
    }
    return _iconImageView;
admin's avatar
admin committed
73 74 75 76 77 78 79 80 81
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end