Bez popisu

KXMarkView.m 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // KXMarkView.m
  3. // CAISHEN
  4. //
  5. // Created by kuxuan on 2017/8/28.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "KXMarkView.h"
  9. @implementation KXMarkView
  10. {
  11. UIView *_whiteView;
  12. }
  13. - (instancetype)initWithFrame:(CGRect)frame
  14. {
  15. if (self = [super initWithFrame:frame]) {
  16. self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
  17. [self setupUI];
  18. }
  19. return self;
  20. }
  21. - (void)setupUI
  22. {
  23. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  24. // app名称
  25. NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
  26. _whiteView = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2.0-150, 180*SCREEN_MUTI, 300, 320)];
  27. _whiteView.center = self.center;
  28. _whiteView.layer.cornerRadius = 8;
  29. _whiteView.layer.masksToBounds = YES;
  30. _whiteView.backgroundColor = [UIColor whiteColor];
  31. [self addSubview:_whiteView];
  32. UILabel *markLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 26, 300, 18)];
  33. markLabel.textColor = [UIColor titleColor];
  34. markLabel.text = [NSString stringWithFormat:@"给%@打分",app_Name];
  35. markLabel.textAlignment = NSTextAlignmentCenter;
  36. markLabel.font = FONT_SYS(16);
  37. [_whiteView addSubview:markLabel];
  38. UILabel *markDetailLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 52, 260, 40)];
  39. markDetailLabel.textColor = [UIColor KXColorWithHex:0x666666];
  40. markDetailLabel.text = [NSString stringWithFormat:@"喜欢新版%@吗?打分鼓励一下吧~您的肯定是我们前进的动力",app_Name];
  41. markDetailLabel.numberOfLines = 0;
  42. markDetailLabel.textAlignment = NSTextAlignmentCenter;
  43. markDetailLabel.font = FONT_SYS(14);
  44. [_whiteView addSubview:markDetailLabel];
  45. UILabel *lineLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 110, 260, 1)];
  46. lineLabel.backgroundColor = [UIColor lineColor];
  47. [_whiteView addSubview:lineLabel];
  48. NSArray *markImageArray = @[@"main_mark_1",@"main_mark_2",@"main_mark_3"];
  49. for (int i = 0; i < 3; i++) {
  50. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  51. button.frame = CGRectMake(50, 130+54*i, 200, 40);
  52. [button setImage:[UIImage imageNamed:markImageArray[i]] forState:UIControlStateNormal];
  53. button.tag = 888 + i;
  54. [button addTarget:self action:@selector(markAction:) forControlEvents:UIControlEventTouchUpInside];
  55. [_whiteView addSubview:button];
  56. }
  57. }
  58. - (void)markAction:(UIButton *)btn
  59. {
  60. [_delegate markViewSelectMarkItem:btn.tag-888];
  61. [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  62. [obj removeFromSuperview];
  63. }];
  64. [self removeFromSuperview];
  65. }
  66. @end