wxr
2020-06-15 b8e94316e41eba72d927d5ca7d931b26139ee8ff
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
45
46
47
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
73
74
75
76
77
78
79
80
81
82
83
84
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
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
141
142
143
144
//
//  HQEditImageActionView.m
//  CivilAviation
//
//  Created by iOS on 2019/3/29.
//  Copyright © 2019 iOS. All rights reserved.
//
 
#import "HQEditImageActionView.h"
 
@interface HQEditImageActionView ()
 
@property (nonatomic, strong) UIView *line;
 
@end
 
@implementation HQEditImageActionView
 
- (instancetype)init {
    if (self = [super init]) {
        
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:.85f];
        
//        [self addSubview:self.rotateButton];
        [self addSubview:self.cancelButton];
//        [self addSubview:self.originButton];
        [self addSubview:self.finishButton];
        
        [self addSubview:self.line];
        
        [self makeConstraints];
    }
    return self;
}
 
- (void)makeConstraints {
    
//    [self.rotateButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(@0);
//        make.top.equalTo(@0);
//        make.width.equalTo(@(25 + 40));
//        make.height.equalTo(@49);
//    }];
    
    [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@20);
        make.width.equalTo(@50);
        make.height.equalTo(@49);
        make.top.equalTo(@49);
    }];
    
//    [self.originButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.width.equalTo(@50);
//        make.height.equalTo(@49);
//        make.top.equalTo(@49);
//        make.centerX.equalTo(@0);
//    }];
    
    [self.finishButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-20);
        make.width.equalTo(@50);
        make.height.equalTo(@49);
        make.top.equalTo(@49);
    }];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@49);
        make.left.right.equalTo(@0);
        make.height.equalTo(@.7f);
    }];
}
 
#pragma mrak - event response
- (void)buttonAction:(UIButton *)button {
    if ([self.delegate respondsToSelector:@selector(action:didClickButton:atIndex:)]) {
        [self.delegate action:self didClickButton:button atIndex:button.tag];
    }
}
 
#pragma mark - getter & setter
//- (UIButton *)rotateButton {
//    if (!_rotateButton) {
//        _rotateButton = [[UIButton alloc] init];
//        
//        [_rotateButton setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_rotate_90_degrees_ccw" ofType:@"png"]] forState:UIControlStateNormal];
//        _rotateButton.tag = 0;
//        _rotateButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
//        [_rotateButton.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.width.height.equalTo(@25);
//            make.center.equalTo(@0);
//        }];
//        [_rotateButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
//    }
//    return _rotateButton;
//}
 
- (UIButton *)cancelButton {
    if (!_cancelButton) {
        _cancelButton = [[UIButton alloc] init];
        
        [_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
        [_cancelButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
        _cancelButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16];
        _cancelButton.tag = 1;
        [_cancelButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cancelButton;
}
 
//- (UIButton *)originButton {
//    if (!_originButton) {
//        _originButton = [[UIButton alloc] init];
//        
//        [_originButton setTitle:@"还原" forState:UIControlStateNormal];
//        [_originButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
//        _originButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16];
//        _originButton.tag = 2;
//        [_originButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
//    }
//    return _originButton;
//}
 
- (UIButton *)finishButton {
    if (!_finishButton) {
        _finishButton = [[UIButton alloc] init];
        
        [_finishButton setTitle:@"完成" forState:UIControlStateNormal];
        [_finishButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
        _finishButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16];
        _finishButton.tag = 3;
        [_finishButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _finishButton;
}
 
- (UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = [UIColor colorWithWhite:1 alpha:.3f];
    }
    return _line;
}
 
@end