BGRoomAnnouncementView.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //
  2. // BGRoomAnnouncementView.m
  3. // UniversalApp
  4. //
  5. // Created by bugu on 2020/3/25.
  6. // Copyright © 2020 voidcat. All rights reserved.
  7. //
  8. #import "BGRoomAnnouncementView.h"
  9. #import "RoomModel.h"
  10. #import "UIView+Voice.h"
  11. @interface BGRoomAnnouncementView ()
  12. @property(nonatomic, strong) UIImageView *bgImageView;
  13. @property(nonatomic, strong) UILabel *titleLabel;
  14. //@property(nonatomic, strong) UILabel *textLabel;
  15. @end
  16. @implementation BGRoomAnnouncementView
  17. /*
  18. // Only override drawRect: if you perform custom drawing.
  19. // An empty implementation adversely affects performance during animation.
  20. - (void)drawRect:(CGRect)rect {
  21. // Drawing code
  22. }
  23. */
  24. - (instancetype)initWithFrame:(CGRect)frame{
  25. if (self = [super initWithFrame:frame]) {
  26. self.backgroundColor = kWhiteColor;
  27. [self addAppTopCornerRadius];
  28. [self.bgImageView addAppTopCornerRadius];
  29. [self initSubview];
  30. }
  31. return self;
  32. }
  33. - (void)initSubview {
  34. self.backgroundColor = [UIColor clearColor];
  35. _bgImageView = ({
  36. UIImageView * imageView = [[UIImageView alloc]init];
  37. imageView.image = [UIImage imageNamed:@"gonggao_bac"];
  38. imageView.contentMode = UIViewContentModeScaleAspectFill;
  39. imageView;
  40. });
  41. _editBtn = ({
  42. UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
  43. [button setImage:[UIImage imageNamed:@"edit1"] forState:UIControlStateNormal];
  44. [button addTarget:self action:@selector(BtnAction:) forControlEvents:UIControlEventTouchUpInside];
  45. // button.hidden = YES;
  46. button;
  47. });
  48. _titleLabel= ({
  49. UILabel * label = [[UILabel alloc]init];
  50. label.textColor = kAppGrayColor1;
  51. label.font = [UIFont boldSystemFontOfSize:19];
  52. label.text = ASLocalizedString(@"房间公告");
  53. // label.textAlignment = NSTextAlignmentCenter;
  54. label;
  55. });
  56. // _textLabel= ({
  57. // UILabel * label = [[UILabel alloc]init];
  58. // label.textColor = [UIColor colorWithHexString:@"#646464"];
  59. // label.font = UIFont.bg_mediumFont15;
  60. // label.numberOfLines = 0;
  61. // // label.textAlignment = NSTextAlignmentCenter;
  62. // label;
  63. // });
  64. _textView = ({
  65. QMUITextView * textView = [[QMUITextView alloc]init];
  66. textView.font = [UIFont systemFontOfSize:15];
  67. textView.textColor = [UIColor colorWithHexString:@"#646464"];
  68. textView.editable = NO;
  69. textView;
  70. });
  71. [self addSubview:_bgImageView];
  72. [self addSubview:_editBtn];
  73. [self addSubview:_titleLabel];
  74. // [self addSubview:_textLabel];
  75. [self addSubview:_textView];
  76. // self.editBtn.hidden=YES;
  77. }
  78. - (void)BtnAction:(UIButton *)sender {
  79. [self hide];
  80. if (self.delegate && [self.delegate respondsToSelector:@selector(announcementView:didClickEditBtn:)]) {
  81. [self.delegate announcementView:self didClickEditBtn:sender];
  82. }
  83. }
  84. - (void)layoutSubviews {
  85. [super layoutSubviews];
  86. [_bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.edges.mas_equalTo(0);
  88. }];
  89. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.centerX.mas_equalTo(0);
  91. make.top.mas_equalTo(27);
  92. }];
  93. [_editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.centerY.equalTo(_titleLabel);
  95. make.right.mas_equalTo(-20);
  96. make.size.mas_equalTo(30);
  97. }];
  98. [_textView mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.mas_equalTo(35);
  100. make.top.equalTo(_titleLabel.mas_bottom).offset(30);
  101. make.height.mas_equalTo(180);
  102. make.centerX.mas_equalTo(0);
  103. }];
  104. }
  105. - (void)setModel:(RoomModel *)model{
  106. _model = model;
  107. // self.editBtn.hidden = ![model.voice.user_id isEqualToString:[IMAPlatform sharedInstance].host.userId];
  108. [self.textView setText:model.voice.announcement];
  109. }
  110. - (void)show:(UIView *)superView{
  111. // if (![self.model.voice.user_id isEqualToString:[IMAPlatform sharedInstance].host.userId]) {
  112. // self.editBtn.hidden = (self.is_host == 0 && self.is_admin == 0);
  113. // }
  114. [super show:superView];
  115. }
  116. @end