123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- //
- // JxnoticeScrollView.m
- // shiku_im
- //
- // Created by 123 on 2020/6/1.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JxnoticeScrollView.h"
- #import "JXLabelObject.h"
- #import "JLSelectModel.h"
- @interface JxnoticeScrollView ()
- @property (nonatomic,strong) UIView *noticeView ;
- @end
- @implementation JxnoticeScrollView
-
- -(instancetype)initWithFrame:(CGRect)frame{
-
- if (self=[super initWithFrame:frame]) {
-
- _noticeView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 40)];
- _noticeView.backgroundColor = [UIColor whiteColor];
- _noticeView.userInteractionEnabled=YES;
- _noticeView.hidden = NO;
- [self addSubview:_noticeView];
-
- _noticeLabel = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
- _noticeLabel.titleLabel.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
- [_noticeLabel setTitle:@"特别关心" forState:UIControlStateNormal];
- [_noticeLabel setTitleColor:HEXCOLOR(0x323232) forState:UIControlStateNormal];
- [_noticeView addSubview:_noticeLabel];
- [_noticeLabel addTarget:self action:@selector(noticeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
-
-
- _noticeTitleScrolView = [[UIScrollView alloc] initWithFrame:CGRectMake(80, 0, JX_SCREEN_WIDTH-95, 40)];
- _noticeTitleScrolView.userInteractionEnabled=YES;
- [self addSubview:_noticeTitleScrolView];
-
-
- [g_notify addObserver:self selector:@selector(act_UserRoomAttention:) name:@"act_UserRoomAttention222" object:nil];
-
-
- }
-
- return self;
- }
-
- -(CGSize)titleBtnWight:(NSString *)titBtnW and:(UIButton *)titBtn {
- CGSize titleSize = [titBtnW boundingRectWithSize:CGSizeMake(MAXFLOAT, 40) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:titBtn.titleLabel.font} context:nil].size;
-
- return titleSize;
- }
-
- - (void)act_UserRoomAttention:(NSNotification *)note{
-
- NSDictionary *dict=note.userInfo;
- NSArray *tempArr=dict[@"user"];
- _dataArr=[tempArr mutableCopy];
- CGFloat titBtnX =10;
- for(int i =0; i <tempArr.count; i++){
-
- memberData *model=tempArr[i];
- UIButton *titBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [titBtn setTitleColor:kRGBColor51 forState:UIControlStateNormal];
- [titBtn setTitle:model.userNickName forState:UIControlStateNormal];
- titBtn.titleLabel.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
- titBtn.backgroundColor=[UIColor whiteColor];
- titBtn.layer.cornerRadius=10;
- titBtn.layer.masksToBounds=YES;
- titBtn.tag=i;
- CGSize titleSize=[self titleBtnWight:model.userNickName and:titBtn];
- CGFloat titBtnW = titleSize.width+5;
- titBtn.frame=CGRectMake(titBtnX, 6, titBtnW, 24);
- titBtnX += titBtnW + 15;
- [_noticeTitleScrolView addSubview:titBtn];
- [titBtn addTarget:self action:@selector(titleUserBtnClick:) forControlEvents:UIControlEventTouchUpInside];
-
- }
-
- self.noticeTitleScrolView.contentSize=CGSizeMake(_dataArr.count *(64)+100, 0);
- }
-
- - (void)noticeBtnClick:(UIButton *)btn{
-
- if (_jxnoticeScrollViewBtnBlock2) {
- _jxnoticeScrollViewBtnBlock2(btn);
- }
- }
- - (void)titleUserBtnClick:(UIButton *)btn{
-
- if (_jxnoticeScrollViewBtnBlock) {
- _jxnoticeScrollViewBtnBlock(btn);
- }
- }
- @end
|