| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- //
- // TiUIDefaultButtonView.m
- // TiSDKDemo
- //
- // Created by iMacA1002 on 2019/12/2.
- // Copyright © 2020 Tillusory Tech. All rights reserved.
- //
- #import "TiUIDefaultButtonView.h"
- #import "TIConfig.h"
- @interface TiUIDefaultButtonView ()
- @property(nonatomic, strong) UIButton *mainSwitchButton;
- //@property(nonatomic, strong) UIButton *cameraCaptureButton;
- //@property(nonatomic, strong) UIButton *switchCameraButton;
- @end
- @implementation TiUIDefaultButtonView
- // MARK: --懒加载--
- -(UIButton *)mainSwitchButton{
- if (_mainSwitchButton==nil){
- _mainSwitchButton = [[UIButton alloc] init];
- [_mainSwitchButton setTag:0];
- [_mainSwitchButton setImage:[UIImage imageNamed:@"btn_meiyan"] forState:UIControlStateNormal];
- [_mainSwitchButton addTarget:self action:@selector(onButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _mainSwitchButton;
- }
- //-(UIButton *)cameraCaptureButton{
- // if (_cameraCaptureButton==nil) {
- // _cameraCaptureButton = [[UIButton alloc] init];
- // [_cameraCaptureButton setTag:1];
- // [_cameraCaptureButton setImage:[UIImage imageNamed:@"btn_take photo"] forState:UIControlStateNormal];
- // [_cameraCaptureButton setImage:[UIImage imageNamed:@"btn_take photo"] forState:UIControlStateSelected];
- // [_cameraCaptureButton addTarget:self action:@selector(onButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- // }
- // return _cameraCaptureButton;
- //}
- //-(UIButton *)switchCameraButton{
- // if (_switchCameraButton==nil) {
- // _switchCameraButton = [[UIButton alloc] init];
- // [_switchCameraButton setTag:2];
- // [_switchCameraButton setImage:[UIImage imageNamed:@"btn_shexiangtou"] forState:UIControlStateNormal];
- // [_switchCameraButton addTarget:self action:@selector(onButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- // }
- // return _switchCameraButton;
- //}
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- [self initView];
- }
- return self;
- }
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self initView];
- }
- return self;
- }
- - (instancetype)initWithCoder:(NSCoder *)coder
- {
- self = [super initWithCoder:coder];
- if (self) {
- [self initView];
- }
- return self;
- }
- -(void)initView{
- [self addSubview:self.mainSwitchButton];
- // [self addSubview:self.cameraCaptureButton];
- // [self addSubview:self.switchCameraButton];
- [self.mainSwitchButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.mas_left).offset(DefaultButton_WIDTH/2.5);
- make.top.equalTo(self.mas_centerY);
- make.width.height.mas_equalTo(DefaultButton_WIDTH-DefaultButton_WIDTH/2);
- }];
- // [self.cameraCaptureButton mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.centerX.equalTo(self.mas_centerX);
- // make.top.equalTo(self.mas_centerY);
- // make.width.height.mas_equalTo(DefaultButton_WIDTH);
- // }];
- // [self.switchCameraButton mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.right.equalTo(self.mas_right).offset(-DefaultButton_WIDTH/2.5);
- // make.top.equalTo(self.mas_centerY);
- // make.width.height.mas_equalTo(DefaultButton_WIDTH-DefaultButton_WIDTH/2);
- // }];
- }
- -(void)onButtonClick:(UIButton *)button{
- if (self.onClickBlock) {
- self.onClickBlock(button.tag);
- }
-
- }
- - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
- UIView *hitView = [super hitTest:point withEvent:event];
- if(hitView == self){
- return nil;
- }
- return hitView;
- }
- @end
|