BGRoomSetNoticeCell.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // BGRoomSetNoticeCell.m
  3. // UniversalApp
  4. //
  5. // Created by bugu on 2020/3/23.
  6. // Copyright © 2020 voidcat. All rights reserved.
  7. //
  8. #import "BGRoomSetNoticeCell.h"
  9. #import "UIFont+Ext.h"
  10. @implementation BGRoomSetNoticeCell
  11. - (void)awakeFromNib {
  12. [super awakeFromNib];
  13. // Initialization code
  14. }
  15. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  16. [super setSelected:selected animated:animated];
  17. // Configure the view for the selected state
  18. }
  19. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  20. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  21. [self initUI];
  22. }
  23. return self;
  24. }
  25. - (void)initUI {
  26. self.bgImageView = ({
  27. UIImageView * imageView = [[UIImageView alloc]init];
  28. imageView.backgroundColor = [UIColor whiteColor];
  29. imageView;
  30. });
  31. ViewRadius(self.bgImageView, 10);
  32. [self.contentView addSubview:self.bgImageView];
  33. [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(0, 10, 0, 10));
  35. }];
  36. self.bgImageView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.15];
  37. self.backgroundColor = [UIColor clearColor];
  38. self.contentView.backgroundColor = [UIColor clearColor];
  39. _titleLabel= ({
  40. UILabel * label = [[UILabel alloc]init];
  41. label.textColor = kAppGrayColor1;
  42. label.font = UIFont.bg_mediumFont16;
  43. label.text = ASLocalizedString(@"房间公告");
  44. label.hidden = YES;
  45. // label.textAlignment = NSTextAlignmentCenter;
  46. label;
  47. });
  48. _titleTextView = ({
  49. QMUITextView * textView = [[QMUITextView alloc]init];
  50. textView.backgroundColor = [UIColor clearColor];
  51. textView.placeholder = ASLocalizedString(@"请设置房间公告");
  52. textView.placeholderColor = [UIColor colorWithHexString:@"#999999"];
  53. textView.font = [UIFont systemFontOfSize:16];
  54. textView.textColor = kWhiteColor;
  55. textView.layer.cornerRadius = 8;
  56. textView.clipsToBounds = YES;
  57. textView.textContainerInset = UIEdgeInsetsMake(13, 16, 13, 16);
  58. //监听文字改变
  59. [[NSNotificationCenter defaultCenter] addObserver:self
  60. selector:@selector(textDidChange:)
  61. name:UITextViewTextDidChangeNotification
  62. object:textView];
  63. textView;
  64. });
  65. [self.contentView addSubview:_titleLabel];
  66. [self.contentView addSubview:_titleTextView];
  67. }
  68. - (void)textDidChange:(NSNotification *)notification {
  69. if(self.textChange)
  70. {
  71. self.textChange(self.titleTextView.text);
  72. }
  73. }
  74. - (void)layoutSubviews {
  75. [super layoutSubviews];
  76. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.left.mas_equalTo(20);
  78. make.top.mas_equalTo(10);
  79. }];
  80. // [_titleTextView mas_makeConstraints:^(MASConstraintMaker *make) {
  81. // make.left.equalTo(_titleLabel);
  82. // make.top.equalTo(_titleLabel.mas_bottom).offset(10);
  83. // make.height.mas_equalTo(75);
  84. // make.centerX.mas_equalTo(0);
  85. // }];
  86. [_titleTextView mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.edges.equalTo(self.bgImageView).insets(UIEdgeInsetsMake(8, 8, 8, 8));
  88. }];
  89. }
  90. @end