BMPopBaseView.m 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // BMPopBaseView.m
  3. // BuguLive
  4. //
  5. // Created by 丁凯 on 2017/5/17.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. #import "BMPopBaseView.h"
  8. @implementation BMPopBaseView
  9. -(void)awakeFromNib
  10. {
  11. [super awakeFromNib];
  12. [self suitAbleScreen];
  13. }
  14. //UI控件适应不同的屏幕
  15. - (void)suitAbleScreen
  16. {
  17. self.userInteractionEnabled = YES;
  18. self.backgroundColor = [kBlackColor colorWithAlphaComponent:0.5];
  19. self.bmButtomView.layer.cornerRadius = 3;
  20. self.bmButtomView.backgroundColor = kAppMainColor;
  21. self.titleLabel.font = [UIFont boldSystemFontOfSize:15];
  22. // self.buttomWidth.constant = self.buttomWidth.constant*kScaleWidth;
  23. // self.buttomHeight.constant = self.buttomHeight.constant*kScaleWidth;
  24. // self.titleLabelWidth.constant = self.titleLabelWidth.constant*kScaleWidth;
  25. // self.titleLabelHeight.constant = self.titleLabelHeight.constant*kScaleWidth;
  26. // self.titlelabelSpaceLeft.constant = self.titlelabelSpaceLeft.constant*kScaleWidth;
  27. // self.closeBtnH.constant = self.closeBtnH.constant*kScaleWidth;
  28. // self.closeBtnW.constant = self.closeBtnW.constant*kScaleWidth;
  29. // self.titleLabelH.constant = self.titleLabelH.constant*kScaleWidth;
  30. }
  31. - (void)updateUIframeWithWidth:(CGFloat)Width andHeight:(CGFloat)Height andTitleStr:(NSString *)titleStr andmyEunmType:(BMPopViewType)myEunmType
  32. {
  33. self.titleLabel.text = titleStr;
  34. self.buttomWidth.constant = Width;
  35. self.buttomHeight.constant = Height;
  36. [self updateUIWithType:myEunmType];
  37. }
  38. - (void)updateUIWithType:(BMPopViewType)myEunmType
  39. {
  40. switch (myEunmType)
  41. {
  42. case BMCreatRoom://创建房间
  43. {
  44. }
  45. break;
  46. case BMRoomInfo://房间信息
  47. {
  48. }
  49. break;
  50. case BMInputPassWord://输密码
  51. {
  52. }
  53. break;
  54. case BMEachDaytask://每日任务
  55. {
  56. self.popType = BMEachDaytask;
  57. // CGRect rect = self.bmButtomView.frame;
  58. // rect.origin.x = kScreenW/2 - 532/4.0f*kScaleWidth;
  59. // rect.origin.y = kScreenH/2 - 466*kScaleHeight/2;
  60. // rect.size.width = 532/2.0f*kScaleWidth;
  61. // rect.size.height = 466*kScaleHeight;
  62. // self.bmButtomView.frame = rect;
  63. self.bmButtomView.center = self.center;
  64. self.bmButtomView.backgroundColor = kClearColor;
  65. // kClearColor;
  66. self.bmButtomView.clipsToBounds = NO;
  67. self.closeBtn.hidden = YES;
  68. self.closeButton.hidden = YES;
  69. //弹窗头图片
  70. UIImageView *popupHeadImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.buttomWidth.constant, kRealValue(101))];
  71. popupHeadImg.image = [UIImage imageNamed:@"bm_dailyTask_headView"];
  72. popupHeadImg.contentMode = UIViewContentModeTop;
  73. popupHeadImg.backgroundColor = kClearColor;
  74. [self.bmButtomView addSubview:popupHeadImg];
  75. //关闭按钮 kAppSpaceColor2
  76. UIButton *closeBtn = [self createCloseButton];
  77. [closeBtn setFrame: CGRectMake(CGRectGetMaxX(self.bmButtomView.frame) - 8, CGRectGetMinY(self.bmButtomView.frame) - 90, 37, 37)];
  78. [self addSubview:closeBtn];
  79. // UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.buttomWidth.constant, self.buttomHeight.constant)];
  80. // [imgView setImage:[UIImage imageNamed:@"bm_daily_task_BgImgView"]];
  81. // [self.bmButtomView addSubview:imgView];
  82. //每日任务表
  83. self.dQTableView = [[DailyQuestTablView alloc]initWithFrame:CGRectMake(kRealValue(10), CGRectGetMaxY(popupHeadImg.frame), self.buttomWidth.constant - kRealValue(12), self.buttomHeight.constant-CGRectGetMaxY(popupHeadImg.frame) - 10 * 2)];
  84. self.dQTableView.backgroundColor = kWhiteColor;
  85. self.dQTableView .layer.cornerRadius = 3;
  86. UIImageView *tableImgView = [UIImageView new];
  87. // tableImgView.image = [UIImage imageNamed:@"bm_daily_task_BgImg"];
  88. tableImgView.backgroundColor = kWhiteColor;
  89. tableImgView.frame = self.dQTableView.frame;
  90. tableImgView.width = self.dQTableView.width + 10;
  91. tableImgView.left = self.dQTableView.left - 10;
  92. tableImgView.height = self.dQTableView.height + 15;
  93. // [BGUtils viewShadowPathWithView:tableImgView Color:<#(UIColor *)#> shadowOpacity:<#(CGFloat)#> shadowRadius:<#(CGFloat)#> shadowPathType:<#(LeShadowPathType)#> shadowPathWidth:<#(CGFloat)#>]
  94. //TODO:uiview 单边圆角或者单边框
  95. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:tableImgView.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10,10)];//圆角大小
  96. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  97. maskLayer.frame = tableImgView.bounds;
  98. maskLayer.path = maskPath.CGPath;
  99. tableImgView.layer.mask = maskLayer;
  100. [self.bmButtomView addSubview:tableImgView];
  101. [self.bmButtomView addSubview:self.dQTableView];
  102. }
  103. break;
  104. default:
  105. break;
  106. }
  107. }
  108. #pragma mark 创建关闭按钮
  109. - (UIButton *)createCloseButton
  110. {
  111. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  112. [closeBtn setBackgroundImage:[UIImage imageNamed:@"bm_personCenter_colse"] forState:UIControlStateNormal];
  113. [closeBtn addTarget:self action:@selector(clsoeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  114. [self addSubview:closeBtn];
  115. return closeBtn;
  116. }
  117. #pragma mark 点击事件(移除view)
  118. - (IBAction)clsoeBtnClick:(UIButton *)sender
  119. {
  120. if (self.popType == BMEachDaytask)
  121. {
  122. self.hidden = YES;
  123. }else
  124. {
  125. [self removeFromSuperview];
  126. }
  127. }
  128. @end