88 lines
2.1 KiB
Objective-C
88 lines
2.1 KiB
Objective-C
//
|
|
// XPSessionListHeadItemView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by GreenLand on 2022/11/17.
|
|
//
|
|
|
|
#import "XPSessionListHeadItemView.h"
|
|
#import <Masonry/Masonry.h>
|
|
#import "ThemeColor.h"
|
|
|
|
@interface XPSessionListHeadItemView()
|
|
|
|
@property (nonatomic, strong) UILabel *nameLabel;
|
|
@property (nonatomic, strong) UIImageView *imageView;
|
|
@property (nonatomic, strong) UIView *dotView;
|
|
|
|
@end
|
|
|
|
@implementation XPSessionListHeadItemView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
if (self = [super initWithFrame:frame]) {
|
|
[self initView];
|
|
[self initContraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)initView {
|
|
[self addSubview:self.imageView];
|
|
[self addSubview:self.nameLabel];
|
|
[self addSubview:self.dotView];
|
|
}
|
|
|
|
- (void)initContraints {
|
|
[self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.centerX.mas_equalTo(0);
|
|
make.width.height.mas_equalTo(50);
|
|
}];
|
|
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.bottom.mas_equalTo(0);
|
|
make.top.mas_equalTo(self.imageView.mas_bottom).mas_offset(8);
|
|
make.bottom.mas_equalTo(0);
|
|
make.height.mas_equalTo(17);
|
|
}];
|
|
[self.dotView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.right.mas_equalTo(self.imageView);
|
|
make.width.height.mas_equalTo(8);
|
|
}];
|
|
}
|
|
|
|
- (void)setTitle:(NSString *)title {
|
|
self.nameLabel.text = title;
|
|
}
|
|
|
|
- (void)setImageName:(NSString *)imageName {
|
|
self.imageView.image = [UIImage imageNamed:imageName];
|
|
}
|
|
|
|
- (UILabel *)nameLabel {
|
|
if (!_nameLabel) {
|
|
_nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
|
_nameLabel.backgroundColor = [UIColor clearColor];
|
|
_nameLabel.font = [UIFont systemFontOfSize:14];
|
|
_nameLabel.textColor = ThemeColor.mainTextColor;
|
|
}
|
|
return _nameLabel;
|
|
}
|
|
|
|
- (UIImageView *)imageView {
|
|
if (!_imageView) {
|
|
_imageView = [[UIImageView alloc] init];
|
|
}
|
|
return _imageView;
|
|
}
|
|
|
|
- (UIView *)dotView {
|
|
if (!_dotView) {
|
|
_dotView = [[UIView alloc] init];
|
|
_dotView.layer.cornerRadius = 4;
|
|
_dotView.layer.masksToBounds = YES;
|
|
}
|
|
return _dotView;
|
|
}
|
|
|
|
@end
|