BGRoomSetHeadCell.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. //
  2. // BGRoomSetHeadCell.m
  3. // UniversalApp
  4. //
  5. // Created by bugu on 2020/3/23.
  6. // Copyright © 2020 voidcat. All rights reserved.
  7. //
  8. #import "BGRoomSetHeadCell.h"
  9. #import "UIFont+Ext.h"
  10. @interface BGRoomSetHeadCell ()
  11. @property(nonatomic, strong) UILabel *titleLabel;
  12. //半透明背景
  13. @property(nonatomic, strong) UIImageView *bgImageView;
  14. @end
  15. @implementation BGRoomSetHeadCell
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. }
  20. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  21. [super setSelected:selected animated:animated];
  22. // Configure the view for the selected state
  23. }
  24. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  25. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  26. [self initUI];
  27. }
  28. return self;
  29. }
  30. - (void)initUI {
  31. self.bgImageView = ({
  32. UIImageView * imageView = [[UIImageView alloc]init];
  33. imageView.backgroundColor = [UIColor whiteColor];
  34. imageView;
  35. });
  36. ViewRadius(self.bgImageView, 10);
  37. [self.contentView addSubview:self.bgImageView];
  38. [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(10, 10, 10, 10));
  40. }];
  41. self.bgImageView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.15];
  42. self.backgroundColor = [UIColor clearColor];
  43. self.contentView.backgroundColor = [UIColor clearColor];
  44. _iconBtn = ({
  45. UIButton * button = [[UIButton alloc]initWithFrame:CGRectZero];
  46. [button setImage:[UIImage imageNamed:@"room_camera"] forState:UIControlStateNormal];
  47. button.layer.cornerRadius = 8;
  48. button.clipsToBounds = YES;
  49. [button addTarget:self action:@selector(BtnAction) forControlEvents:UIControlEventTouchUpInside];
  50. button.backgroundColor = [UIColor clearColor];
  51. button;
  52. });
  53. _titleLabel= ({
  54. UILabel * label = [[UILabel alloc]init];
  55. label.textColor = kAppGrayColor1;
  56. label.font = UIFont.bg_mediumFont16;
  57. label.text = ASLocalizedString(@"房间名称");
  58. label.hidden = YES;
  59. // label.textAlignment = NSTextAlignmentCenter;
  60. label;
  61. });
  62. _iconTipLabel= ({
  63. UILabel * label = [[UILabel alloc]init];
  64. label.textColor = kWhiteColor;
  65. label.font = [UIFont systemFontOfSize:11];
  66. label.text = ASLocalizedString(@"设置房间头像");
  67. label.backgroundColor = [kBlackColor colorWithAlphaComponent:0.38];
  68. label.textAlignment = NSTextAlignmentCenter;
  69. //
  70. // label.textAlignment = NSTextAlignmentCenter;
  71. label;
  72. });
  73. _titleTextField = ({
  74. QMUITextField * TF = [[QMUITextField alloc]init];
  75. TF.backgroundColor = [UIColor clearColor];
  76. TF.placeholder = ASLocalizedString(@"给房间取个名~");
  77. TF.placeholderColor = [UIColor colorWithHexString:@"#FFFFFF"];
  78. TF.textColor = kWhiteColor;
  79. TF.font = [UIFont systemFontOfSize:16];
  80. TF.layer.cornerRadius = 8;
  81. TF.clipsToBounds = YES;
  82. TF.textInsets = UIEdgeInsetsMake(0, 16, 0, 16);
  83. TF;
  84. });
  85. [self.contentView addSubview:_iconBtn];
  86. [self.contentView addSubview:_iconTipLabel];
  87. [self.contentView addSubview:_titleLabel];
  88. [self.contentView addSubview:_titleTextField];
  89. _iconTipLabel.frame = CGRectMake(kScreenW-22-83, 93-17, 100, 17);
  90. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_iconTipLabel.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(8,8)];//圆角大小
  91. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  92. maskLayer.frame = _iconTipLabel.bounds;
  93. maskLayer.path = maskPath.CGPath;
  94. _iconTipLabel.layer.mask = maskLayer;
  95. }
  96. - (void)layoutSubviews {
  97. [super layoutSubviews];
  98. [_iconBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.mas_equalTo(20);
  100. make.centerY.mas_equalTo(0);
  101. make.width.height.mas_equalTo(100);
  102. }];
  103. [_iconTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.right.mas_equalTo(self.iconBtn);
  105. make.bottom.equalTo(_iconBtn);
  106. make.width.mas_equalTo(_iconBtn);
  107. make.height.mas_equalTo(17);
  108. }];
  109. //
  110. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.left.mas_equalTo(20);
  112. make.top.mas_equalTo(16+10);
  113. }];
  114. [_titleTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  115. make.left.equalTo(self.iconBtn.mas_right).offset(9.5);
  116. make.top.equalTo(self.iconBtn.mas_top).offset(11);
  117. make.height.mas_equalTo(36);
  118. make.right.equalTo(self.mas_right).offset(-71);
  119. }];
  120. }
  121. - (void)BtnAction {
  122. if (self.selectImgBlock) {
  123. self.selectImgBlock();
  124. }
  125. }
  126. @end