123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- //
- // SDTimeLineTableHeaderView.m
- // GSD_WeiXin(wechat)
- //
- // Created by gsd on 16/2/25.
- // Copyright © 2016年 GSD. All rights reserved.
- //
- #import "SDTimeLineTableHeaderView.h"
- #import "UIView+SDAutoLayout.h"
- #import "SLNewMsgBgView.h"
- #import "SLMomentsNewsVc.h"
- #import "SLMsgBgSetVc.h"
- @implementation SDTimeLineTableHeaderView
- {
- UIImageView *_backgroundImageView;
- UIImageView *_iconView;
- UILabel *_nameLabel;
- UIScrollView *_interestcrollView;
- SLNewMsgBgView *_newMsgBgView;
-
- }
- - (instancetype)initWithFrame:(CGRect)frame
- {
- if (self = [super initWithFrame:frame]) {
- [self setup];
- }
- return self;
- }
- - (void)setup
- {
- _backgroundImageView = [UIImageView new];
- _backgroundImageView.image = ImageName(@"icon_moment_bg_01");
- _backgroundImageView.userInteractionEnabled = YES;
- [self addSubview:_backgroundImageView];
-
- _iconView = [UIImageView new];
- [self addSubview:_iconView];
-
- _nameLabel = [UILabel new];
- SLLoginInfo *targetModel = [SLGlobalInfo SharedInstance].loginInfo;
- _nameLabel.text = targetModel.user.userName;
- _nameLabel.textColor = [UIColor whiteColor];
- _nameLabel.textAlignment = NSTextAlignmentRight;
- _nameLabel.font = [UIFont boldSystemFontOfSize:15];
- [self addSubview:_nameLabel];
-
-
- _interestcrollView = [[UIScrollView alloc] initWithFrame:CGRectZero];
- _interestcrollView.bounces = NO;
- _interestcrollView.showsVerticalScrollIndicator = NO;
- _interestcrollView.showsHorizontalScrollIndicator = NO;
- [self addSubview:_interestcrollView];
-
- NSMutableArray *marr = [NSMutableArray arrayWithArray:@[@"运动",@"运动",@"运动",@"运动"]];
- [marr removeAllObjects];
- [marr enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull stop) {
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
- label.text = obj;
- label.frame = CGRectMake(60 * idx, 0, 48, 26);
- label.textColor = [UIColor whiteColor];
- label.font = [UIFont systemFontOfSize:10];
- label.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.3];
- label.layer.cornerRadius = 13.0;
- label.textAlignment = NSTextAlignmentCenter;
- label.clipsToBounds = YES;
- [_interestcrollView addSubview:label];
- }];
-
- UIButton *moreInterestBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [moreInterestBtn setImage:ImageName(@"icon_right_arrow_b") forState:UIControlStateNormal];
- [moreInterestBtn handleEvent:UIControlEventTouchUpInside withBlock:^{
-
- }];
- moreInterestBtn.hidden = YES;
- [self addSubview:moreInterestBtn];
-
- _newMsgBgView = [[SLNewMsgBgView alloc] initWithFrame:CGRectZero];
- _newMsgBgView.hidden = YES;
- [self addSubview:_newMsgBgView];
-
- _backgroundImageView.sd_layout.spaceToSuperView(UIEdgeInsetsMake(0, 0, 30, 0));
- UIView *topView = [[UIView alloc] init];
- topView.backgroundColor = [UIColor whiteColor];
- [self addSubview:topView];
- topView.sd_layout
- .heightIs(54)
- .leftSpaceToView(self, 0)
- .rightSpaceToView(self, 0)
- .topSpaceToView(self, -54);
- _iconView.sd_layout
- .widthIs(64)
- .heightIs(64)
- .leftSpaceToView(self, 16)
- .bottomSpaceToView(self, 84);
- _iconView.layer.cornerRadius = 32.0f;
- _iconView.clipsToBounds = YES;
- _iconView.contentMode = UIViewContentModeScaleAspectFill;
-
- _nameLabel.tag = 1000;
- [_nameLabel setSingleLineAutoResizeWithMaxWidth:200];
- _nameLabel.sd_layout
- .leftSpaceToView(_iconView, 9)
- .centerYEqualToView(_iconView)
- .heightIs(24);
- _interestcrollView.sd_layout
- .heightIs(26)
- .leftSpaceToView(self, 16)
- .rightSpaceToView(self, 50)
- .bottomSpaceToView(self, 54);
- moreInterestBtn.sd_layout
- .widthIs(26)
- .heightIs(26)
- .rightSpaceToView(self, 12)
- .centerYEqualToView(_interestcrollView);
-
- _newMsgBgView.sd_layout
- .centerXEqualToView(self)
- .bottomSpaceToView(self, 30)
- .widthIs(126)
- .heightIs(46);
- _newMsgBgView.layer.cornerRadius = 26.0;
- _newMsgBgView.clipsToBounds = YES;
- WS(weakSelf);
- [_newMsgBgView addTapWithBlock:^{
- SLMomentsNewsVc *vc = [SLMomentsNewsVc loadViewControllewWithNib];
- [weakSelf.viewController navPushViewController:vc animated:YES];
- SLLoginInfo *newLoginModel = [SLGlobalInfo SharedInstance].loginInfo;
- newLoginModel.user.momentsMsgNotice = @"";
- [SLGlobalInfo SharedInstance].loginInfo = newLoginModel;
- }];
-
- self.bgSelImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
- self.bgSelImageView.image = ImageName(@"icon_moment_bg_sel");
- self.bgSelImageView.hidden = YES;
- [self addSubview:self.bgSelImageView];
- self.bgSelImageView.sd_layout
- .widthIs(56)
- .heightIs(56)
- .rightSpaceToView(self, 16)
- .centerYEqualToView(_iconView);
- [self.bgSelImageView addTapWithBlock:^{
- SLMsgBgSetVc *vc = [SLMsgBgSetVc loadViewControllewWithNib];
- [weakSelf.viewController navPushViewController:vc animated:YES];
- }];
- }
- - (void)confignHeaderWith:(SLUserModel *)userModel {
- NSString *urlStr = [userModel getUserHeadUrl];
- [_iconView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:ImageName(@"icon_ellipse")];
- _nameLabel.text = userModel.userName;
- NSString *bgImg = [NSString stringWithFormat:@"%@%@",[SLHttpCenter SharedInstance].serverUrl, userModel.friendCircleImage];
- [_backgroundImageView sd_setImageWithURL:[NSURL URLWithString:bgImg] placeholderImage:ImageName(@"icon_moment_bg_01")];
- }
- - (void)updateHeaderViewWith:(NSString *)momentsMsgNotice {
- if (momentsMsgNotice.length && [momentsMsgNotice integerValue]) {
- _backgroundImageView.sd_resetLayout.spaceToSuperView(UIEdgeInsetsMake(0, 0, 100, 0));
- _newMsgBgView.hidden = NO;
- _newMsgBgView.contentLabel.text = [NSString stringWithFormat:@"%@条新消息",momentsMsgNotice];
- }else {
- _backgroundImageView.sd_resetLayout.spaceToSuperView(UIEdgeInsetsMake(0, 0, 30, 0));
- _newMsgBgView.hidden = YES;
- }
- }
- @end
|