123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // XYMarkingFriendsMainSkillTopView.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/12/7.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYMarkingFriendsMainSkillTopView.h"
- @interface XYMarkingFriendsMainSkillTopView ()
- @property (nonatomic, strong) UIView *matchUserView;
- @property (nonatomic, strong) UILabel *arrowTextLabel;
- @property (nonatomic, strong) UIImageView *arrowImageView;
- @property (nonatomic, strong) UIButton *quickMatchButton;
- @end
- @implementation XYMarkingFriendsMainSkillTopView
- - (void)setupMatchUserArray:(NSArray *)array {
- [_matchUserView removeFromSuperview];
- _matchUserView = nil;
- _matchUserView = [[UIView alloc] init];
- _matchUserView.backgroundColor = [UIColor clearColor];
- [self addSubview:_matchUserView];
- [_matchUserView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self).offset(16.0f);
- make.centerY.equalTo(self);
- make.width.equalTo(@84.0f);
- make.height.equalTo(@24.0f);
- }];
- [_matchUserView layoutIfNeeded];
-
- UIImageView *tempView;
- for (int i = 0; i < array.count; i++) {
- XYUserModel *model = array[i];
- if (i < 4) {
- UIImageView *avatarImgView = [[UIImageView alloc] init];
- [avatarImgView sd_setImageWithURL:[NSURL URLWithString:model.userAvatar] placeholderImage:placeholderUserMainBgImage(model.userSex)];
- avatarImgView.contentMode = UIViewContentModeScaleAspectFill;
- [_matchUserView addSubview:avatarImgView];
- [avatarImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- if (tempView) { make.left.equalTo(tempView).offset(20.0f); }
- else{ make.left.equalTo(self).offset(20.0f); }
- make.centerY.equalTo(self);
- make.width.equalTo(@24.0f);
- make.height.equalTo(@24.0f);
- }];
- [avatarImgView layoutIfNeeded];
- kViewRadius(avatarImgView, 12);
- tempView = avatarImgView;
- }
- }
-
- }
- #pragma mark — Action
- - (void)quickMatchButtonAction:(id)sender {
- if (self.quickMatchBlock) {
- self.quickMatchBlock();
- }
- }
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- [self setupUI];
- }
- return self;
- }
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self setupUI];
- }
- return self;
- }
- - (void)setupUI {
- [self addSubview:self.arrowTextLabel];
- [self addSubview:self.arrowImageView];
- [self addSubview:self.quickMatchButton];
-
- [self.arrowTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self);
- }];
- [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.arrowTextLabel.mas_left).offset(-4.0f);
- make.centerY.equalTo(self.arrowTextLabel);
- make.width.height.equalTo(@6.0f);
- }];
- [self.quickMatchButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self).offset(-16.0f);
- make.centerY.equalTo(self);
- make.width.equalTo(@64.0f);
- make.height.equalTo(@22.0f);
- }];
-
- [self.quickMatchButton addViewBorder:Color_Clear redian:11];
- }
- #pragma mark — Getter
- - (UILabel *)arrowTextLabel {
- if (!_arrowTextLabel) {
- _arrowTextLabel = [UILabel createLabelTextColor:ColorFromHexStringWithAlpha(@"#D4C1FF", 0.5f) fount:Font(10)];
- _arrowTextLabel.textAlignment = NSTextAlignmentCenter;
- _arrowTextLabel.text = kLocalizedString(@"下拉快速匹配");
- }
- return _arrowTextLabel;
- }
- - (UIImageView *)arrowImageView {
- if (!_arrowImageView) {
- _arrowImageView = [UIImageView new];
- _arrowImageView.image = ImageNamed(@"xy_friend_skill_arrow");
- }
- return _arrowImageView;
- }
- - (UIButton *)quickMatchButton {
- if (!_quickMatchButton) {
- _quickMatchButton = [UIButton createButtonTextColor:Color_White textFont:Font(10)];
- [_quickMatchButton setTitle:kLocalizedString(@"快速匹配") forState:UIControlStateNormal];
- [_quickMatchButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[ColorFromHexString(@"#5F0AFF"), ColorFromHexString(@"#9858FF")] gradientType:GradientTypeUpleftToLowright imgSize:CGSizeMake(64.0f, 22.0f)] forState:UIControlStateNormal];
- [_quickMatchButton addTarget:self action:@selector(quickMatchButtonAction:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _quickMatchButton;
- }
- @end
|