添加了粉丝和关注列表我的等级
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "XPMacro.h"
|
||||
#import "UIImage+Utils.h"
|
||||
|
||||
@implementation XPMineAccountSubView
|
||||
@@ -105,9 +106,9 @@
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self).inset(15);
|
||||
make.left.mas_equalTo(self).offset(15);
|
||||
make.top.bottom.mas_equalTo(self);
|
||||
make.right.mas_equalTo(self.recommendView.mas_left).offset(-15);;
|
||||
make.width.mas_equalTo((KScreenWidth - 15 * 3) / 2);
|
||||
}];
|
||||
|
||||
[self.recommendView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
|
21
xplan-ios/Main/Mine/View/SubViews/XPMineFriendNumberView.h
Normal file
21
xplan-ios/Main/Mine/View/SubViews/XPMineFriendNumberView.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// XPMineFriendNumberView.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/12/21.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPMineFriendNumberView : UIView
|
||||
|
||||
///显示数量
|
||||
@property (nonatomic,copy) NSString *number;
|
||||
///显示标题
|
||||
@property (nonatomic,copy) NSString *title;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
82
xplan-ios/Main/Mine/View/SubViews/XPMineFriendNumberView.m
Normal file
82
xplan-ios/Main/Mine/View/SubViews/XPMineFriendNumberView.m
Normal file
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// XPMineFriendNumberView.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/12/21.
|
||||
//
|
||||
|
||||
#import "XPMineFriendNumberView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
|
||||
@interface XPMineFriendNumberView ()
|
||||
///显示个数
|
||||
@property (nonatomic,strong) UILabel *numberLabel;
|
||||
///显示标题
|
||||
@property (nonatomic,strong) UILabel *titleLabel;
|
||||
@end
|
||||
|
||||
@implementation XPMineFriendNumberView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.numberLabel];
|
||||
[self addSubview:self.titleLabel];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.titleLabel.mas_bottom);
|
||||
}];
|
||||
|
||||
[self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.mas_equalTo(self);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.numberLabel.mas_bottom).offset(8);
|
||||
make.left.right.mas_equalTo(self);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setTitle:(NSString *)title {
|
||||
self.titleLabel.text = title;
|
||||
}
|
||||
|
||||
- (void)setNumber:(NSString *)number {
|
||||
self.numberLabel.text = number;
|
||||
}
|
||||
|
||||
- (UILabel *)numberLabel {
|
||||
if (!_numberLabel) {
|
||||
_numberLabel = [[UILabel alloc] init];
|
||||
_numberLabel.font = [UIFont boldSystemFontOfSize:18];
|
||||
_numberLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_numberLabel.textColor = [ThemeColor mainTextColor];
|
||||
}
|
||||
return _numberLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
_titleLabel.textColor = [ThemeColor secondTextColor];
|
||||
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
@end
|
@@ -16,6 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)xPMineHeadView:(XPMineHeadView *)view didClickAccount:(UserInfoModel *)info;
|
||||
//点击邀请好友
|
||||
- (void)xPMineHeadView:(XPMineHeadView *)view didClickInviteFriend:(UserInfoModel *)info;
|
||||
///点击了关注
|
||||
- (void)xpMineHeadViewClickAttention;
|
||||
///点击了粉丝
|
||||
- (void)xpMineHeadViewClickFans;
|
||||
@end
|
||||
@interface XPMineHeadView : UIView
|
||||
///用户信息
|
||||
|
@@ -8,14 +8,16 @@
|
||||
#import "XPMineHeadView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <YYText/YYLabel.h>
|
||||
#import <YYText/YYText.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "XPMacro.h"
|
||||
#import "UIImage+Utils.h"
|
||||
///View
|
||||
#import "XPMineAccountView.h"
|
||||
#import "NetImageView.h"
|
||||
#import "UIImage+Utils.h"
|
||||
#import "XPMineFriendNumberView.h"
|
||||
///Model
|
||||
#import "UserInfoModel.h"
|
||||
|
||||
@@ -38,6 +40,12 @@
|
||||
@property (nonatomic,strong) YYLabel *levelLabel;
|
||||
///我的账户 推荐给好友
|
||||
@property (nonatomic,strong) XPMineAccountView *accountView;
|
||||
///分割线
|
||||
@property (nonatomic,strong) UIView * lineView;
|
||||
///关注
|
||||
@property (nonatomic,strong) XPMineFriendNumberView *attentionView;
|
||||
///粉丝
|
||||
@property (nonatomic,strong) XPMineFriendNumberView *fansView;
|
||||
@end
|
||||
|
||||
@implementation XPMineHeadView
|
||||
@@ -71,6 +79,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tapFansRecognizer {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickFans)]) {
|
||||
[self.delegate xpMineHeadViewClickFans];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tapAttentionRecognizer {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickAttention)]) {
|
||||
[self.delegate xpMineHeadViewClickAttention];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
@@ -78,6 +98,9 @@
|
||||
[self addSubview:self.nameStackView];
|
||||
[self addSubview:self.idStackView];
|
||||
[self addSubview:self.levelLabel];
|
||||
[self addSubview:self.lineView];
|
||||
[self addSubview:self.attentionView];
|
||||
[self addSubview:self.fansView];
|
||||
[self addSubview:self.accountView];
|
||||
|
||||
[self.nameStackView addArrangedSubview:self.nameLabel];
|
||||
@@ -99,7 +122,7 @@
|
||||
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(50, 50));
|
||||
make.left.mas_equalTo(self).offset(20);
|
||||
make.top.mas_equalTo(self).offset(50 + kSafeAreaTopHeight);
|
||||
make.top.mas_equalTo(self).offset(30 + kSafeAreaTopHeight);
|
||||
}];
|
||||
|
||||
[self.nameStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -117,13 +140,195 @@
|
||||
make.top.mas_equalTo(self.idStackView.mas_bottom).offset(4);
|
||||
}];
|
||||
|
||||
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(1, 30));
|
||||
make.centerY.mas_equalTo(self.idLabel.mas_bottom).offset(2);
|
||||
make.left.mas_equalTo(self.idLabel.mas_right).offset(30);
|
||||
}];
|
||||
|
||||
[self.attentionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.lineView.mas_right);
|
||||
make.centerY.mas_equalTo(self.lineView);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
|
||||
[self.fansView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.centerY.mas_equalTo(self.attentionView);
|
||||
make.left.mas_equalTo(self.attentionView.mas_right);
|
||||
}];
|
||||
|
||||
[self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self);
|
||||
make.height.mas_equalTo(60);
|
||||
make.top.mas_equalTo(self.avatarImageView.mas_bottom).offset(30);
|
||||
make.top.mas_equalTo(self.avatarImageView.mas_bottom).offset(30 + 20);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - NSMutableAttributedString
|
||||
-(NSInteger) getMonth:(long )time
|
||||
{
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
|
||||
NSCalendar* calendar = [NSCalendar currentCalendar];
|
||||
NSDateComponents* components = [calendar components:NSCalendarUnitMonth fromDate:date];
|
||||
NSInteger month = components.month;
|
||||
return month;
|
||||
}
|
||||
|
||||
- (NSInteger) getDay:(long) time
|
||||
{
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
|
||||
NSCalendar* calendar = [NSCalendar currentCalendar];
|
||||
NSDateComponents* components = [calendar components:NSCalendarUnitDay fromDate:date];
|
||||
NSInteger day = components.day;
|
||||
return day;
|
||||
}
|
||||
|
||||
- (NSString *)calculateConstellationWithMonth:(long)time
|
||||
{
|
||||
NSString *astroString = @"魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
|
||||
NSString *astroFormat = @"102123444543";
|
||||
NSString *result;
|
||||
|
||||
NSInteger month = [self getMonth:time];
|
||||
NSInteger day = [self getDay:time];
|
||||
|
||||
if (month<1 || month>12 || day<1 || day>31){
|
||||
return @"错误日期格式!";
|
||||
}
|
||||
|
||||
if(month==2 && day>29)
|
||||
{
|
||||
return @"错误日期格式!!";
|
||||
}else if(month==4 || month==6 || month==9 || month==11) {
|
||||
if (day>30) {
|
||||
return @"错误日期格式!!!";
|
||||
}
|
||||
}
|
||||
|
||||
result=[NSString stringWithFormat:@"%@",[astroString substringWithRange:NSMakeRange(month*2-(day < [[astroFormat substringWithRange:NSMakeRange((month-1), 1)] intValue] - (-19))*2,2)]];
|
||||
|
||||
return [NSString stringWithFormat:@"%@座",result];
|
||||
}
|
||||
|
||||
/// 生成一个图片的富文本
|
||||
/// @param imageUrl 网络图片的地址
|
||||
- (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl {
|
||||
NetImageConfig *config = [[NetImageConfig alloc]init];
|
||||
///先这样吧
|
||||
config.autoLoad = YES;
|
||||
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config];
|
||||
UIImage* image = imageView.image;
|
||||
if (image) {
|
||||
CGFloat scale = image.size.width / image.size.height;
|
||||
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
||||
} else {
|
||||
NSURL *imgUrl = [NSURL URLWithString:imageUrl];
|
||||
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
||||
CGFloat scale = myImage.size.width / myImage.size.height;
|
||||
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
||||
}
|
||||
imageView.layer.masksToBounds = YES;
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
return attrString;
|
||||
}
|
||||
|
||||
/// 占位的富文本
|
||||
/// @param width 需要的间隙
|
||||
- (NSMutableAttributedString *)createSapceAttribute:(CGFloat)width {
|
||||
UIView *spaceView = [[UIView alloc]init];
|
||||
spaceView.backgroundColor = [UIColor clearColor];
|
||||
spaceView.bounds = CGRectMake(0, 0, width, 10);
|
||||
NSMutableAttributedString * attribute = [NSMutableAttributedString yy_attachmentStringWithContent:spaceView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(spaceView.frame.size.width, spaceView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
return attribute;
|
||||
}
|
||||
|
||||
//dateLabel
|
||||
- (NSMutableAttributedString *)makeDateLabel:(long)birth{
|
||||
NSString *dateStr = [NSString stringWithFormat:@" %@ ",[self calculateConstellationWithMonth:birth]];
|
||||
UIButton *dataButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[dataButton setTitle:dateStr forState:UIControlStateNormal];
|
||||
dataButton.titleLabel.font = [UIFont boldSystemFontOfSize:10];
|
||||
[dataButton setTitleColor:UIColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
|
||||
dataButton.frame = CGRectMake(0, 0, 45, 17);
|
||||
dataButton.layer.masksToBounds = YES;
|
||||
dataButton.layer.cornerRadius = 17/2;
|
||||
[dataButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
||||
NSMutableAttributedString * dateLabelString = [NSMutableAttributedString yy_attachmentStringWithContent:dataButton contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(dataButton.frame.size.width, dataButton.frame.size.height) alignToFont:[UIFont systemFontOfSize:11] alignment:YYTextVerticalAlignmentCenter];
|
||||
return dateLabelString;
|
||||
}
|
||||
|
||||
///铭牌
|
||||
- (NSMutableAttributedString *)createNameplateAttibute:(NSString *)tagName image:(NSString *)imageName textFont:(UIFont *)textFont {
|
||||
NetImageConfig *config = [[NetImageConfig alloc]init];
|
||||
///先这样吧
|
||||
config.autoLoad = YES;
|
||||
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageName config:config];
|
||||
UIImage* image = imageView.image;
|
||||
if (image) {
|
||||
CGFloat scale = image.size.width / image.size.height;
|
||||
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
||||
} else {
|
||||
NSURL *imgUrl = [NSURL URLWithString:imageName];
|
||||
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
||||
CGFloat scale = myImage.size.width / myImage.size.height;
|
||||
if (scale == 0) {
|
||||
imageView.bounds = CGRectMake(0, 0, 60, 20);
|
||||
}else {
|
||||
imageView.bounds = CGRectMake(0, 0, 20* scale, 20);
|
||||
}
|
||||
}
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
// 铭牌文字
|
||||
UILabel *label = [[UILabel alloc] init];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
label.font = [UIFont boldSystemFontOfSize:12];
|
||||
label.adjustsFontSizeToFitWidth = YES;
|
||||
label.textColor = UIColor.whiteColor;
|
||||
label.text = tagName;
|
||||
[imageView addSubview:label];
|
||||
[label mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(27);
|
||||
make.right.mas_equalTo(-8);
|
||||
make.centerY.mas_equalTo(0);
|
||||
}];
|
||||
NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.bounds.size alignToFont:[UIFont boldSystemFontOfSize:12] alignment:YYTextVerticalAlignmentCenter];
|
||||
return string;
|
||||
}
|
||||
|
||||
///当装扮铭牌时,我的页面中不需要显示铭牌标识
|
||||
- (NSMutableAttributedString *)creatNameplateLevleAttribute:(UserInfoModel *)userInfo {
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
|
||||
|
||||
if (!userInfo) {
|
||||
return attributedString;
|
||||
}
|
||||
//主播认证
|
||||
if (userInfo.nameplateWord.length > 0 && userInfo.nameplatePic.length>0) {
|
||||
[self createNameplateAttibute:userInfo.nameplateWord image:userInfo.nameplatePic textFont:[UIFont systemFontOfSize:9]];
|
||||
[attributedString appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
// userRank 用户级别
|
||||
if (userInfo.userLevelVo.experUrl) {
|
||||
[attributedString appendAttributedString:[self createUrlImageAttribute:userInfo.userLevelVo.experUrl]];
|
||||
[attributedString appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
//charmRank 魅力等级
|
||||
if (userInfo.userLevelVo.charmUrl) {
|
||||
[attributedString appendAttributedString:[self createUrlImageAttribute:userInfo.userLevelVo.charmUrl]];
|
||||
[attributedString appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
// constellation 星座
|
||||
if (userInfo.birth) {
|
||||
[attributedString appendAttributedString:[self makeDateLabel:userInfo.birth]];
|
||||
}
|
||||
return attributedString;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
||||
_userInfo = userInfo;
|
||||
@@ -148,6 +353,9 @@
|
||||
sexName = @"common_female";
|
||||
}
|
||||
self.sexImageView.image = [UIImage imageNamed:sexName];
|
||||
self.levelLabel.attributedText = [self creatNameplateLevleAttribute:_userInfo];
|
||||
self.fansView.number = [NSString stringWithFormat:@"%ld",_userInfo.fansNum];
|
||||
self.attentionView.number = [NSString stringWithFormat:@"%ld",_userInfo.followNum];
|
||||
}
|
||||
}
|
||||
- (NetImageView *)avatarImageView {
|
||||
@@ -236,5 +444,33 @@
|
||||
return _accountView;
|
||||
}
|
||||
|
||||
- (UIView *)lineView {
|
||||
if (!_lineView) {
|
||||
_lineView = [[UIView alloc] init];
|
||||
_lineView.backgroundColor = [ThemeColor dividerColor];
|
||||
}
|
||||
return _lineView;
|
||||
}
|
||||
|
||||
- (XPMineFriendNumberView *)attentionView {
|
||||
if (!_attentionView) {
|
||||
_attentionView = [[XPMineFriendNumberView alloc] init];
|
||||
_attentionView.title = @"关注";
|
||||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAttentionRecognizer)];
|
||||
[_attentionView addGestureRecognizer:tap];
|
||||
}
|
||||
return _attentionView;
|
||||
}
|
||||
|
||||
- (XPMineFriendNumberView *)fansView {
|
||||
if (!_fansView) {
|
||||
_fansView = [[XPMineFriendNumberView alloc] init];
|
||||
_fansView.title = @"粉丝";
|
||||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapFansRecognizer)];
|
||||
[_fansView addGestureRecognizer:tap];
|
||||
}
|
||||
return _fansView;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user