TaxisView.m 6.27 KB
Newer Older
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 44
//
//  TaxisView.m
//  redstar
//
//  Created by admin on 15/11/10.
//  Copyright © 2015年 ZWF. All rights reserved.
//

#import "TaxisView.h"

@implementation TaxisView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setup];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup
{
    [self.defaultBtn setTitle:@"默认排序" forState:UIControlStateNormal];
    [self.sequenceBtn setTitle:@"时间顺序排序" forState:UIControlStateNormal];

    [self.changeoverBtn setTitle:@"时间逆序排序" forState:UIControlStateNormal];

}

#pragma mark - Lazy loading
- (UIButton *)defaultBtn
{
    if (!_defaultBtn) {
        _defaultBtn = [[UIButton alloc] init];
45 46 47
        _defaultBtn.layer.borderWidth = 0.5;
        _defaultBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
        _defaultBtn.layer.borderColor = kSeparateLineCGColor;
48
        _defaultBtn.translatesAutoresizingMaskIntoConstraints = NO;
49 50 51
        [_defaultBtn setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
        _defaultBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
        _defaultBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
        [self addSubview:_defaultBtn];
        
        // 顶端
        NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_defaultBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
        [self addConstraint:titleTop];
        
        // 左边
        NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_defaultBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
        [self addConstraint:titleLeft];
        
        // 右边
        NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_defaultBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
        [self addConstraint:titleRight];
        
        // 右边
        NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_defaultBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.sequenceBtn attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0];
        [self addConstraint:titleHeight];
    }
    return _defaultBtn;
}

- (UIButton *)sequenceBtn
{
    if (!_sequenceBtn) {
        _sequenceBtn = [[UIButton alloc] init];
77
        _sequenceBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
78
        _sequenceBtn.translatesAutoresizingMaskIntoConstraints = NO;
79 80 81 82 83 84
        _sequenceBtn.layer.borderColor = kSeparateLineCGColor;
        _sequenceBtn.layer.borderWidth = 0.5;
        [_sequenceBtn setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
        _sequenceBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
        _sequenceBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
        [self addSubview:_sequenceBtn];
        
        // 顶端
        NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_sequenceBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_defaultBtn attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
        [self addConstraint:titleTop];
        
        // 左边
        NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_sequenceBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
        [self addConstraint:titleLeft];
        
        // 右边
        NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_sequenceBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
        [self addConstraint:titleRight];
        
        // 右边
        NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_sequenceBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.changeoverBtn attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0];
        [self addConstraint:titleHeight];
    }
    return _sequenceBtn;
}

- (UIButton *)changeoverBtn
{
    if (!_changeoverBtn) {
        _changeoverBtn = [[UIButton alloc] init];
110 111 112 113
        _changeoverBtn.layer.borderColor = kSeparateLineCGColor;
        _changeoverBtn.layer.borderWidth = 0.5;
        _changeoverBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
        _changeoverBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
114
        _changeoverBtn.translatesAutoresizingMaskIntoConstraints = NO;
115 116
        [_changeoverBtn setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
        _changeoverBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
        [self addSubview:_changeoverBtn];
        
        // 顶端
        NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_changeoverBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_sequenceBtn attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
        [self addConstraint:titleTop];
        
        // 左边
        NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_changeoverBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
        [self addConstraint:titleLeft];
        
        // 右边
        NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_changeoverBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
        [self addConstraint:titleRight];
        
        // 右边
        NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_changeoverBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
        [self addConstraint:titleBottom];
    }
    return _changeoverBtn;
}

@end