You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

176 lines
6.3 KiB

//
// MyTableViewHeaderView.m
// tongxin
//
// Created by ecell on 2023/6/21.
// Copyright © 2023 xTT. All rights reserved.
//
#import "MyTableViewHeaderView.h"
#import "User.h"
@interface MyTableViewHeaderView ()
/// 设备头像
@property (nonatomic ,weak) UIImageView *iconImg;
/// 设备名称
@property (nonatomic ,weak) UILabel *nameLabel;
@property (nonatomic ,weak) UILabel *idLabel;
@property (nonatomic ,weak) UILabel *line;
@end
@implementation MyTableViewHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.frame = [UIScreen mainScreen].bounds;
[self subHeadView];
}
return self;
}
- (void)subHeadView
{
UIView *bgView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKWhiteColorColor];
[self addSubview:bgView];
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.mas_left).offset(20);
make.top.equalTo(self.mas_top).offset(15);
make.right.equalTo(self.mas_right).inset(20);
// make.height.mas_equalTo(136);
make.height.mas_equalTo(85);
}];
/// 设备头像
UIImageView *iconImg = [UIImageView new];
iconImg.layer.cornerRadius = 25;
iconImg.layer.masksToBounds = YES;
self.iconImg = iconImg;
[bgView addSubview:iconImg];
[iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(bgView.mas_left).offset(15);
make.top.equalTo(bgView.mas_top).offset(13);
make.size.mas_equalTo(CGSizeMake(50, 50));
}];
UIButton *btn = [UICommon ui_buttonSimple:CGRectZero font:Font_(0) normalColor:KKClearColor normalText:@"" click:^(id x) {
[UICommon pusXibViewController:@"EditMeViewController"];
}];
[bgView addSubview:btn];
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(bgView);
make.top.equalTo(bgView);
make.bottom.equalTo(iconImg.mas_bottom);
}];
/// 设备名称
UILabel *nameLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBold_(16) textColor:KKTextColor text:@"" Radius:0];
self.nameLabel = nameLabel;
[bgView addSubview:nameLabel];
[nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(iconImg.mas_right).offset(20);
make.top.equalTo(iconImg.mas_top).offset(5);
}];
UILabel *idLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:RGB(133, 133, 133) text:@"" Radius:0];
self.idLabel = idLabel;
[bgView addSubview:idLabel];
[idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(nameLabel.mas_left);
make.bottom.equalTo(iconImg.mas_bottom).inset(5);
}];
/// 右箭头图片
UIImageView *rightImg = [UICommon ui_imageView:CGRectZero fileName:@"comm_right_icon"];
[bgView addSubview:rightImg];
[rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(bgView.mas_right).inset(36);
make.centerY.equalTo(iconImg.mas_centerY);
make.size.mas_equalTo(CGSizeMake(8, 15));
}];
UILabel *ttLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:RGB(133, 133, 133) text:@"编辑资料" Radius:0];
[bgView addSubview:ttLabel];
[ttLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(rightImg.mas_left).inset(10);
make.centerY.equalTo(rightImg.mas_centerY);
}];
// CGFloat ww = (ScreenWidth-40)/3;
// NSArray *titleArr = @[@"0\n剩余金币",@"0\n收藏",@"0\n记录"];
// for (int i = 0; i < titleArr.count; i++)
// {
// UILabel *label = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBold_(24) textColor:KKTextColor text:@"" Radius:0];
// label.attributedText = [UICommon labelFontSize:titleArr[i] :@""];
// [bgView addSubview:label];
// [label mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.equalTo(bgView.mas_left).offset(i*ww);
// make.top.equalTo(iconImg.mas_bottom).offset(11);
// make.size.mas_equalTo(CGSizeMake(ww, 45));
// }];
//
// if (i < titleArr.count-1)
// {
// UILabel *line = [UILabel new];
// line.backgroundColor = RGB(235, 235, 235);
// [bgView addSubview:line];
// [line mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.equalTo(label.mas_right);
// make.centerY.equalTo(label);
// make.size.mas_equalTo(CGSizeMake(1, 45));
// }];
// }
// }
// UIButton *leftBtn = [UICommon ui_buttonSimple:CGRectZero font:Font_(0) normalColor:KKClearColor normalText:@"" click:^(id x) {
//
// }];
// [leftBtn setImage:ImageName_(@"my_vip_kt_icon") forState:0];
// [self addSubview:leftBtn];
// [leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.equalTo(self).offset(20);
// make.top.equalTo(bgView.mas_bottom).offset(20);
// make.right.equalTo(self.mas_centerX).inset(7.5);
// make.height.mas_equalTo(67);
// }];
//
// UIButton *rightBtn = [UICommon ui_buttonSimple:CGRectZero font:Font_(0) normalColor:KKClearColor normalText:@"" click:^(id x) {
//
// }];
// [rightBtn setImage:ImageName_(@"my_vip_zx_icon") forState:0];
// [self addSubview:rightBtn];
// [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.centerY.equalTo(leftBtn);
// make.right.equalTo(self.mas_right).inset(20);
// make.left.equalTo(self.mas_centerX).offset(7.5);
// make.height.mas_equalTo(67);
// }];
}
- (void)seCellModel
{
[self.iconImg sd_setImageWithURL:[NSURL URLWithString:cUser.avator]
placeholderImage:[myHelper getImageWithName:@"默认用户头像"]
options:SDWebImageRetryFailed];
self.nameLabel.text = cUser.name;
self.idLabel.text = [NSString stringWithFormat:@"账号:%@",cUser.phone];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end