1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- //
- // LZMScreenshotShareView.m
- // YouHuiProject
- //
- // Created by jcymac on 2018/6/7.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LZMScreenshotShareView.h"
- @interface LZMScreenshotShareView()
- @property(nonatomic,strong)UIView *btnArrayView;
- @property(nonatomic,strong)NSMutableArray *btnArray;
- @end
- @implementation LZMScreenshotShareView
- 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<sum; i++) {
- UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
- btn.tag=1000+i;
- [[btn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
- UIButton *btn=(UIButton *)x;
- if (self.btnBlock) {
- self.btnBlock(btn.tag);
- }
- [self removeFromSuperview];
-
- }];
- btn.backgroundColor=[UIColor grayColor];
- btn.frame=CGRectMake(offLeft+i*(btnWidth+btnInterval), 0, btnWidth, btnWidth);
- [_btnArray addObject:btn];
- }
- }
- return _btnArray;
- }
- @end
|