新UI马甲包

HCScreenshotShareView.m 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // HCScreenshotShareView.m
  3. // hc
  4. //
  5. // Created by jcymac on 2018/6/7.
  6. // Copyright © 2018年 hc. All rights reserved.
  7. //
  8. #import "HCScreenshotShareView.h"
  9. @interface HCScreenshotShareView()
  10. @property(nonatomic,strong)UIView *btnArrayView;
  11. @property(nonatomic,strong)NSMutableArray *btnArray;
  12. @end
  13. @implementation HCScreenshotShareView
  14. static float btnArrayOffLeft;
  15. static float btnWidth;
  16. -(instancetype)initWithFrame:(CGRect)frame{
  17. if (self=[super initWithFrame:frame]) {
  18. btnArrayOffLeft=FITSIZE(50);
  19. btnWidth=FITSIZE(50);
  20. self.backgroundColor=[UIColor redColor];
  21. [self addUI];
  22. [self adjustUI];
  23. }
  24. return self;
  25. }
  26. -(void)addUI{
  27. [self addSubview:self.imageView];
  28. [self addSubview:self.btnArrayView];
  29. }
  30. -(void)adjustUI{
  31. [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.mas_equalTo(FITSIZE(btnArrayOffLeft));
  33. make.right.mas_equalTo(FITSIZE(-btnArrayOffLeft));
  34. make.top.mas_equalTo(FITSIZE(btnArrayOffLeft));
  35. make.height.mas_equalTo((SCREEN_HEIGHT*(SCREEN_WIDTH-2*btnArrayOffLeft)/SCREEN_WIDTH));
  36. }];
  37. [self.btnArrayView mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.equalTo(self.imageView.mas_left);
  39. make.right.equalTo(self.imageView.mas_right);
  40. make.top.equalTo(self.imageView.mas_bottom).offset(20);
  41. make.height.mas_equalTo(btnWidth);
  42. }];
  43. }
  44. -(UIView *)btnArrayView{
  45. if (!_btnArrayView) {
  46. _btnArrayView=[[UIView alloc]init];
  47. for (UIButton *btn in self.btnArray) {
  48. [_btnArrayView addSubview:btn];
  49. }
  50. _btnArrayView.backgroundColor=[UIColor greenColor];
  51. }
  52. return _btnArrayView;
  53. }
  54. - (UIImageView *)imageView{
  55. if (!_imageView) {
  56. _imageView=[[UIImageView alloc]init];
  57. _imageView.backgroundColor=[UIColor grayColor];
  58. }
  59. return _imageView;
  60. }
  61. -(NSMutableArray *)btnArray{
  62. if (!_btnArray) {
  63. _btnArray=[NSMutableArray array];
  64. NSInteger sum=3;
  65. float offLeft=FITSIZE(10);
  66. float btnInterval=(((SCREEN_WIDTH-2*btnArrayOffLeft)-2*offLeft)-sum*btnWidth)/(sum-1);
  67. for (int i=0; i<sum; i++) {
  68. UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
  69. btn.tag=1000+i;
  70. [[btn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
  71. UIButton *btn=(UIButton *)x;
  72. if (self.btnBlock) {
  73. self.btnBlock(btn.tag);
  74. }
  75. [self removeFromSuperview];
  76. }];
  77. btn.backgroundColor=[UIColor grayColor];
  78. btn.frame=CGRectMake(offLeft+i*(btnWidth+btnInterval), 0, btnWidth, btnWidth);
  79. [_btnArray addObject:btn];
  80. }
  81. }
  82. return _btnArray;
  83. }
  84. @end