| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- //
- // FocusOnCollectCell.m
- // BuguLive
- //
- // Created by bugu on 2019/11/29.
- // Copyright © 2019 xfg. All rights reserved.
- //
- #import "FocusOnCollectCell.h"
- @interface FocusOnCollectCell ()
- @property(nonatomic, strong) UIImageView *bgImageView;
- @property(nonatomic, strong) UIImageView *iconImageView;
- @property(nonatomic, strong) UILabel *nickNameLabel;
- @property(nonatomic, strong) UIButton *followBtn;
- @end
- static NSString *const image_name_bg = @"关注背景";
- static NSString *const image_name_btn = @"bogo_follow_btn";
- @implementation FocusOnCollectCell
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self initUI];
- }
- return self;
- }
- - (void)initUI{
-
- _bgImageView = ({
- UIImageView *imageView = [[UIImageView alloc] init];
- imageView.image = [UIImage imageNamed:image_name_bg];
- imageView;
- });
- _iconImageView = ({
- UIImageView *imageView = [[UIImageView alloc] init];
- imageView.clipsToBounds = YES;
- imageView.layer.cornerRadius = 25;
- imageView.userInteractionEnabled = YES;
- imageView.image = [UIImage imageNamed:@"com_preload_head_img"];
- UITapGestureRecognizer *tapImg = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickImgView:)];
- [imageView addGestureRecognizer:tapImg];
- imageView;
- });
- _nickNameLabel= ({
- UILabel * label = [[UILabel alloc]init];
- label.textColor = [UIColor colorWithHexString:@"#666666"];
- label.font = [UIFont systemFontOfSize:14];
- label.textAlignment = NSTextAlignmentCenter;
- label.text = ASLocalizedString(@"小草莓");
- label;
- });
-
- _followBtn = ({
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- // [btn setBackgroundImage:[UIImage imageNamed:ASLocalizedString(@"bogo_follow_btn")] forState:UIControlStateNormal];
- btn.layer.borderColor = [UIColor colorWithHexString:@"B956D2"].CGColor;
- btn.backgroundColor = UIColor.whiteColor;
- btn.layer.borderWidth = 1;
- [btn setTitleColor:[UIColor colorWithHexString:@"B956D2"] forState:UIControlStateNormal];
- [btn setTitle:ASLocalizedString(@"+关注") forState:UIControlStateNormal];
- [btn.titleLabel sizeToFit];
- btn.titleLabel.font = [UIFont systemFontOfSize:13];
- btn.layer.cornerRadius = 25/2;
- btn.layer.masksToBounds = YES;
-
- [btn.titleLabel setAdjustsFontSizeToFitWidth:YES];
- [btn addTarget:self action:@selector(followAction) forControlEvents:UIControlEventTouchUpInside];
- btn;
- });
-
-
- [self.contentView addSubview:_bgImageView];
- [self.contentView addSubview:_iconImageView];
- [self.contentView addSubview:_nickNameLabel];
- [self.contentView addSubview:_followBtn];
- }
- - (void)followAction {
- if (self.followBlock) {
- self.followBlock();
- }
-
- // !self.followBlock ? : self.followBlock();
- }
- -(void)clickImgView:(UITapGestureRecognizer *)sender{
- if (self.clickImgBlock) {
- self.clickImgBlock(self.user.id);
- }
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
-
-
- [_bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self).insets(UIEdgeInsetsMake(0, 0, 0, 0));
- }];
-
- [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(kRealValue(15));
- make.centerX.equalTo(self);
- make.size.mas_equalTo(kRealValue(50));
- }];
-
- [_nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_iconImageView.mas_bottom).offset(kRealValue(3));
- make.width.mas_equalTo(self.contentView.width - kRealValue(15));
- make.centerX.equalTo(self);
- }];
-
- [_followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.bottom.mas_equalTo(-15);
- make.top.equalTo(_nickNameLabel.mas_bottom).offset(3);
- make.centerX.equalTo(self);
- make.width.mas_equalTo(kRealValue(52));
- make.height.mas_equalTo(kRealValue(25));
- }];
- }
- - (void)setUser:(HMHotItemModel *)user{
- _user = user;
- self.nickNameLabel.text = user.nick_name;
- [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:user.head_image] placeholderImage:kDefaultPreloadHeadImg];
- if ([user.id isEqualToString:[BGIMLoginManager sharedInstance].loginParam.identifier]) {
- self.followBtn.hidden = YES;
- }else{
- // self.followBtn.hidden = NO;
- }
- }
- @end
|