1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // WHMineBottomItemView.m
- // MSYOUPAI
- //
- // Created by 刘必果 on 2024/2/1.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "WHMineBottomItemView.h"
- @implementation WHMineBottomItemView
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if(self){
- [self initUI];
- [self loadLayout];
- [self setBackgroundColor:[UIColor whiteColor]];
- [self.layer setCornerRadius:WHScreenEqualWidth(8)];
- [self.layer setMasksToBounds:YES];
- [self mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(WHScreenEqualWidth(86));
- make.width.mas_greaterThanOrEqualTo(WHScreenEqualWidth(68));
- }];
- }
- return self;
- }
- - (void)setSourceDic:(NSDictionary *)sourceDic{
- _sourceDic = sourceDic;
- [self.imageView setImage:sourceDic[@"image"]];
- [self.title setText:sourceDic[@"title"]];
- }
- - (void)initUI{
- [self addSubview:self.imageView];
- [self addSubview:self.title];
- [self addSubview:self.action];
- }
- - (void)loadLayout{
- [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(WHScreenEqualWidth(24));
- make.centerX.equalTo(self);
- make.top.equalTo(self).offset(WHScreenEqualWidth(17));
- }];
- [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self);
- make.top.equalTo(self.imageView.mas_bottom).offset(WHScreenEqualWidth(8));
- make.height.mas_equalTo(WHScreenEqualWidth(17));
- }];
- [self.action mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- }];
- }
- #pragma mark - get set
- //UIImageView *imageView;
- - (UIImageView *)imageView{
- if(!_imageView){
- _imageView = [[UIImageView alloc] init];
- }
- return _imageView;
- }
- //UILabel *title;
- - (UILabel *)title{
- if(!_title){
- _title = [[UILabel alloc] init];
- [_title setTextColor:HexColorFromRGB(0x171A1D)];
- [_title setFont:[UIFont systemFontOfSize:WHScreenEqualWidth(12)]];
- }
- return _title;
- }
- //UIControl *action;
- - (UIControl *)action{
- if(!_action){
- _action = [[UIControl alloc] init];
- [_action addTarget:self action:@selector(actionEvent) forControlEvents:UIControlEventTouchUpInside];
- }
- return _action;
- }
- - (void)actionEvent{
- if(self.itemBlock){
- self.itemBlock(self.sourceDic);
- }
- }
- @end
|