YBLinkAlertView.m 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // YBLinkAlertView.m
  3. // yunbaolive
  4. //
  5. // Created by Boom on 2018/10/29.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "YBLinkAlertView.h"
  9. @interface YBLinkAlertView()
  10. @property(nonatomic,strong)NSString *applyUid;
  11. @end
  12. @implementation YBLinkAlertView{
  13. NSDictionary *userMsg;
  14. UIView *whiteView;
  15. }
  16. - (instancetype)initWithFrame:(CGRect)frame andUserMsg:(NSDictionary *)dic{
  17. self = [self initWithFrame:frame];
  18. self.backgroundColor = [UIColor clearColor];
  19. userMsg = dic;
  20. if (self) {
  21. [self creatUI];
  22. }
  23. return self;
  24. }
  25. - (void)creatUI{
  26. self.isHostToHost = NO;
  27. if (![PublicObj checkNull:minstr([userMsg valueForKey:@"pkuid"])]) {
  28. self.isHostToHost = YES;
  29. }
  30. self.applyUid = minstr([userMsg valueForKey:@"uid"]);
  31. whiteView = [[UIView alloc]initWithFrame:CGRectMake(_window_width*(95/750.00000), _window_height/2-100, _window_width*(560/750.00000), 200)];
  32. whiteView.backgroundColor = [UIColor whiteColor];
  33. whiteView.layer.cornerRadius = 5.0;
  34. whiteView.layer.masksToBounds = YES;
  35. [self addSubview:whiteView];
  36. UIImageView *headerImgview =[[ UIImageView alloc]initWithFrame:CGRectMake(whiteView.width/2-22.5, 15, 45, 45)];
  37. [headerImgview sd_setImageWithURL:[NSURL URLWithString:minstr([userMsg valueForKey:@"uhead"])]];
  38. headerImgview.layer.cornerRadius = 22.5;
  39. headerImgview.layer.masksToBounds = YES;
  40. [whiteView addSubview:headerImgview];
  41. //UILabel *nameL = [[UILabel alloc]initWithFrame:CGRectMake(0, headerImgview.bottom, whiteView.width, 29)];
  42. UILabel *nameL = [[UILabel alloc]init];
  43. nameL.textColor = RGB_COLOR(@"#646566", 1);
  44. nameL.font = [UIFont boldSystemFontOfSize:15];
  45. nameL.textAlignment = NSTextAlignmentCenter;
  46. nameL.text = minstr([userMsg valueForKey:@"uname"]);
  47. [whiteView addSubview:nameL];
  48. [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.top.equalTo(headerImgview.mas_bottom);
  50. make.height.mas_equalTo(29);
  51. make.centerX.equalTo(whiteView.mas_centerX).offset(-10);
  52. }];
  53. //UIImageView *sexImgView =[[ UIImageView alloc]initWithFrame:CGRectMake(whiteView.width/2-25, nameL.bottom, 18, 15)];
  54. UIImageView *sexImgView = [[UIImageView alloc]init];
  55. if ([minstr([userMsg valueForKey:@"sex"]) isEqual:@"1"]) {
  56. sexImgView.image = [UIImage imageNamed:@"bullet-男"];
  57. }else{
  58. sexImgView.image = [UIImage imageNamed:@"bullet-女"];
  59. }
  60. [whiteView addSubview:sexImgView];
  61. [sexImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.width.mas_equalTo(18);
  63. make.height.mas_equalTo(15);
  64. make.centerY.mas_equalTo(nameL.mas_centerY);
  65. make.left.equalTo(nameL.mas_right).offset(1);
  66. }];
  67. /*
  68. UIImageView *levelImgView =[[ UIImageView alloc]initWithFrame:CGRectMake(sexImgView.right+5, sexImgView.top, 30, 15)];
  69. if ([userMsg valueForKey:@"level_anchor"]) {
  70. NSDictionary *levelDic = [common getAnchorLevelMessage:minstr([userMsg valueForKey:@"level_anchor"])];
  71. [levelImgView sd_setImageWithURL:[NSURL URLWithString:minstr([levelDic valueForKey:@"thumb"])]];
  72. }else{
  73. NSDictionary *levelDic = [common getUserLevelMessage:minstr([userMsg valueForKey:@"level"])];
  74. [levelImgView sd_setImageWithURL:[NSURL URLWithString:minstr([levelDic valueForKey:@"thumb"])]];
  75. }
  76. [whiteView addSubview:levelImgView];
  77. */
  78. //_timeL = [[UILabel alloc]initWithFrame:CGRectMake(0, sexImgView.bottom, whiteView.width, 41)];
  79. _timeL = [[UILabel alloc]init];
  80. _timeL.textAlignment = NSTextAlignmentCenter;
  81. _timeL.textColor = RGB_COLOR(@"#636465", 1);
  82. [whiteView addSubview:_timeL];
  83. [_timeL mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.width.centerX.equalTo(whiteView);
  85. make.top.equalTo(nameL.mas_bottom).offset(12);
  86. }];
  87. [PublicObj lineViewWithFrame:CGRectMake(0, whiteView.height-51, whiteView.width, 1) andColor:RGB_COLOR(@"#e3e4e5", 1) andView:whiteView];
  88. NSArray *btnTitleArr = @[YZMsg(@"拒绝"),YZMsg(@"接受")];
  89. for (int i = 0; i< btnTitleArr.count; i++) {
  90. UIButton *btn = [UIButton buttonWithType:0];
  91. btn.frame = CGRectMake((whiteView.width/2+0.5)*i, whiteView.height-50, whiteView.width/2-0.5, 50);
  92. btn.tag = i+1000;
  93. [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  94. [btn setTitle:btnTitleArr[i] forState:0];
  95. if (i == 0) {
  96. [btn setTitleColor:RGB_COLOR(@"#636465", 1) forState:0];
  97. btn.titleLabel.font = [UIFont systemFontOfSize:15];
  98. [PublicObj lineViewWithFrame:CGRectMake(btn.right, btn.top, 1, btn.height) andColor:RGB_COLOR(@"#e3e4e5", 1) andView:whiteView];
  99. }else{
  100. [btn setTitleColor:Pink_Cor forState:0];
  101. btn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
  102. }
  103. [whiteView addSubview:btn];
  104. }
  105. }
  106. - (void)btnClick:(UIButton *)sender{
  107. if (sender.tag == 1000) {
  108. self.linkAlertEvent(NO,self.isHostToHost);
  109. }else{
  110. self.linkAlertEvent(YES,self.isHostToHost);
  111. }
  112. [UIView animateWithDuration:0.3 animations:^{
  113. whiteView.transform = CGAffineTransformMakeScale(0.01, 0.01);
  114. }completion:^(BOOL finished) {
  115. [self removeFromSuperview];
  116. }];
  117. }
  118. - (void)show{
  119. [UIView animateWithDuration:0.3 animations:^{
  120. whiteView.transform = CGAffineTransformMakeScale(1, 1);
  121. }completion:^(BOOL finished) {
  122. }];
  123. }
  124. @end