117 lines
2.7 KiB
Objective-C
117 lines
2.7 KiB
Objective-C
//
|
|
// XPMonentsTopicHeaderView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/8/18.
|
|
//
|
|
|
|
#import "XPMonentsTopicHeaderView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
#import "XPMacro.h"
|
|
#import "NetImageView.h"
|
|
///Model
|
|
#import "MonentsTopicModel.h"
|
|
|
|
@interface XPMonentsTopicHeaderView ()
|
|
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
@property (nonatomic,strong) UILabel *descLabel;
|
|
@property (nonatomic,strong) NetImageView *logoImageView;
|
|
@property (nonatomic,strong) UIView * alphaView;
|
|
@end
|
|
|
|
@implementation XPMonentsTopicHeaderView
|
|
|
|
|
|
- (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.logoImageView];
|
|
[self addSubview:self.alphaView];
|
|
[self addSubview:self.titleLabel];
|
|
[self addSubview:self.descLabel];
|
|
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self);
|
|
}];
|
|
|
|
[self.alphaView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self).offset(kNavigationHeight + 10);
|
|
make.left.mas_equalTo(self).offset(30);
|
|
}];
|
|
|
|
[self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.titleLabel);
|
|
make.right.mas_equalTo(self).offset(-10);
|
|
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(20);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setTopicInfo:(MonentsTopicModel *)topicInfo {
|
|
_topicInfo = topicInfo;
|
|
if (_topicInfo) {
|
|
self.logoImageView.imageUrl = _topicInfo.icon;
|
|
self.titleLabel.text = _topicInfo.name;
|
|
self.descLabel.text = _topicInfo.desc;
|
|
}
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.font = [UIFont systemFontOfSize:18];
|
|
_titleLabel.textColor = [UIColor whiteColor];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UILabel *)descLabel {
|
|
if (!_descLabel) {
|
|
_descLabel = [[UILabel alloc] init];
|
|
_descLabel.font = [UIFont systemFontOfSize:14];
|
|
_descLabel.textColor = [UIColor whiteColor];
|
|
_descLabel.numberOfLines = 2;
|
|
}
|
|
return _descLabel;
|
|
}
|
|
|
|
- (NetImageView *)logoImageView {
|
|
if (!_logoImageView) {
|
|
_logoImageView = [[NetImageView alloc] init];
|
|
_logoImageView.userInteractionEnabled = YES;
|
|
_logoImageView.layer.masksToBounds = YES;
|
|
_logoImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
}
|
|
return _logoImageView;
|
|
}
|
|
|
|
- (UIView *)alphaView {
|
|
if (!_alphaView) {
|
|
_alphaView = [[UIView alloc] init];
|
|
_alphaView.backgroundColor = [UIColor blackColor];
|
|
_alphaView.alpha = 0.5;
|
|
}
|
|
return _alphaView;
|
|
}
|
|
|
|
@end
|