// // YZMAScreenshotShareView.m // YouHuiProject // // Created by jcymac on 2018/6/7. // Copyright © 2018年 kuxuan. All rights reserved. // #import "YZMAScreenshotShareView.h" @interface YZMAScreenshotShareView() @property(nonatomic,strong)UIView *btnArrayView; @property(nonatomic,strong)NSMutableArray *btnArray; @end @implementation YZMAScreenshotShareView static float btnArrayOffLeft; static float btnWidth; -(instancetype)initWithFrame:(CGRect)frame{ if (self=[super initWithFrame:frame]) { btnArrayOffLeft=FITSIZE(50); btnWidth=FITSIZE(50); self.backgroundColor=[UIColor redColor]; [self addUI]; [self adjustUI]; } return self; } -(void)addUI{ [self addSubview:self.imageView]; [self addSubview:self.btnArrayView]; } -(void)adjustUI{ [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(FITSIZE(btnArrayOffLeft)); make.right.mas_equalTo(FITSIZE(-btnArrayOffLeft)); make.top.mas_equalTo(FITSIZE(btnArrayOffLeft)); make.height.mas_equalTo((SCREEN_HEIGHT*(SCREEN_WIDTH-2*btnArrayOffLeft)/SCREEN_WIDTH)); }]; [self.btnArrayView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.imageView.mas_left); make.right.equalTo(self.imageView.mas_right); make.top.equalTo(self.imageView.mas_bottom).offset(20); make.height.mas_equalTo(btnWidth); }]; } -(UIView *)btnArrayView{ if (!_btnArrayView) { _btnArrayView=[[UIView alloc]init]; for (UIButton *btn in self.btnArray) { [_btnArrayView addSubview:btn]; } _btnArrayView.backgroundColor=[UIColor greenColor]; } return _btnArrayView; } - (UIImageView *)imageView{ if (!_imageView) { _imageView=[[UIImageView alloc]init]; _imageView.backgroundColor=[UIColor grayColor]; } return _imageView; } -(NSMutableArray *)btnArray{ if (!_btnArray) { _btnArray=[NSMutableArray array]; NSInteger sum=3; float offLeft=FITSIZE(10); float btnInterval=(((SCREEN_WIDTH-2*btnArrayOffLeft)-2*offLeft)-sum*btnWidth)/(sum-1); for (int i=0; i