InpectPictureCell.m 6.81 KB
Newer Older
admin's avatar
admin committed
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
//
//
//  redstar
//
//  Created by admin on 15/11/27.
//  Copyright © 2015年 ZWF. All rights reserved.
//

#import "InpectPictureCell.h"

@implementation InpectPictureCell

#pragma mark - System Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setup];
    }
    return self;
}

#pragma mark - Private Methods
- (void)setup
{
26
    self.contentView.backgroundColor = [UIColor colorWithRed:239 / 255.0 green:239 / 255.0 blue:239 / 255.0 alpha:239 / 255.0];
admin's avatar
admin committed
27 28
}

29
- (UIButton *)photoButton1
admin's avatar
admin committed
30
{
31 32 33 34
    if (!_photoButton1) {
        _photoButton1 = [[UIButton alloc] init];
        _photoButton1.translatesAutoresizingMaskIntoConstraints = NO;
        [self.contentView addSubview:_photoButton1];
admin's avatar
admin committed
35 36
        
        NSLayoutConstraint *overDateTop = [NSLayoutConstraint
37
                                           constraintWithItem:_photoButton1
admin's avatar
admin committed
38 39 40 41 42 43 44 45
                                           attribute:NSLayoutAttributeTop
                                           relatedBy:NSLayoutRelationEqual
                                           toItem:self.contentView
                                           attribute:NSLayoutAttributeTop
                                           multiplier:1.0
                                           constant:5];
        [self.contentView addConstraint:overDateTop];
        
46 47
        NSLayoutConstraint *overDateLeft = [NSLayoutConstraint
                                            constraintWithItem:_photoButton1
admin's avatar
admin committed
48 49 50 51 52 53
                                            attribute:NSLayoutAttributeLeft
                                            relatedBy:NSLayoutRelationEqual
                                            toItem:self.contentView
                                            attribute:NSLayoutAttributeLeft
                                            multiplier:1.0
                                            constant:20];
54
        [self.contentView addConstraint:overDateLeft];
admin's avatar
admin committed
55
        
56 57
        NSLayoutConstraint *overDateRight = [NSLayoutConstraint
                                             constraintWithItem:_photoButton1
admin's avatar
admin committed
58 59 60 61 62 63
                                             attribute:NSLayoutAttributeRight
                                             relatedBy:NSLayoutRelationEqual
                                             toItem:self.contentView
                                             attribute:NSLayoutAttributeRight
                                             multiplier:1.0
                                             constant:-(kScreenWidth / 2 + 10)];
64
        [self.contentView addConstraint:overDateRight];
admin's avatar
admin committed
65 66
        
        NSLayoutConstraint *overDateHeight = [NSLayoutConstraint
67
                                             constraintWithItem:_photoButton1
admin's avatar
admin committed
68 69 70 71 72 73 74 75 76
                                             attribute:NSLayoutAttributeHeight
                                             relatedBy:NSLayoutRelationEqual
                                             toItem:nil
                                             attribute:NSLayoutAttributeNotAnAttribute
                                             multiplier:1.0
                                             constant:90];
        [self.contentView addConstraint:overDateHeight];
        
        NSLayoutConstraint *overDateBottom = [NSLayoutConstraint
77
                                              constraintWithItem:_photoButton1
admin's avatar
admin committed
78 79 80 81 82 83 84 85
                                              attribute:NSLayoutAttributeBottom
                                              relatedBy:NSLayoutRelationEqual
                                              toItem:self.contentView
                                              attribute:NSLayoutAttributeBottom
                                              multiplier:1.0
                                              constant:-5];
        [self.contentView addConstraint:overDateBottom];
    }
86
    return _photoButton1;
admin's avatar
admin committed
87 88
}

89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
- (UIButton *)photoButton2
{
    if (!_photoButton2) {
        _photoButton2 = [[UIButton alloc] init];
        _photoButton2.translatesAutoresizingMaskIntoConstraints = NO;
        [self.contentView addSubview:_photoButton2];
        
        NSLayoutConstraint *overDateTop = [NSLayoutConstraint
                                           constraintWithItem:_photoButton2
                                           attribute:NSLayoutAttributeTop
                                           relatedBy:NSLayoutRelationEqual
                                           toItem:self.contentView
                                           attribute:NSLayoutAttributeTop
                                           multiplier:1.0
                                           constant:5];
        [self.contentView addConstraint:overDateTop];
        
        NSLayoutConstraint *overDateLeft = [NSLayoutConstraint
                                            constraintWithItem:_photoButton2
                                            attribute:NSLayoutAttributeLeft
                                            relatedBy:NSLayoutRelationEqual
                                            toItem:self.contentView
                                            attribute:NSLayoutAttributeLeft
                                            multiplier:1.0
                                            constant:kScreenWidth / 2 + 10];
        [self.contentView addConstraint:overDateLeft];
        
        NSLayoutConstraint *overDateRight = [NSLayoutConstraint
                                             constraintWithItem:_photoButton2
                                             attribute:NSLayoutAttributeRight
                                             relatedBy:NSLayoutRelationEqual
                                             toItem:self.contentView
                                             attribute:NSLayoutAttributeRight
                                             multiplier:1.0
                                             constant:-20];
        [self.contentView addConstraint:overDateRight];
        
        NSLayoutConstraint *overDateHeight = [NSLayoutConstraint
                                              constraintWithItem:_photoButton2
                                              attribute:NSLayoutAttributeHeight
                                              relatedBy:NSLayoutRelationEqual
                                              toItem:nil
                                              attribute:NSLayoutAttributeNotAnAttribute
                                              multiplier:1.0
                                              constant:90];
        [self.contentView addConstraint:overDateHeight];
        
    }
    return _photoButton2;
}


admin's avatar
admin committed
141 142 143 144 145 146 147
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end