WHMineBottomItemView.m 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // WHMineBottomItemView.m
  3. // MSYOUPAI
  4. //
  5. // Created by 刘必果 on 2024/2/1.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "WHMineBottomItemView.h"
  9. @implementation WHMineBottomItemView
  10. - (instancetype)initWithFrame:(CGRect)frame{
  11. self = [super initWithFrame:frame];
  12. if(self){
  13. [self initUI];
  14. [self loadLayout];
  15. [self setBackgroundColor:[UIColor whiteColor]];
  16. [self.layer setCornerRadius:WHScreenEqualWidth(8)];
  17. [self.layer setMasksToBounds:YES];
  18. [self mas_makeConstraints:^(MASConstraintMaker *make) {
  19. make.height.mas_equalTo(WHScreenEqualWidth(86));
  20. make.width.mas_greaterThanOrEqualTo(WHScreenEqualWidth(68));
  21. }];
  22. }
  23. return self;
  24. }
  25. - (void)setSourceDic:(NSDictionary *)sourceDic{
  26. _sourceDic = sourceDic;
  27. [self.imageView setImage:sourceDic[@"image"]];
  28. [self.title setText:sourceDic[@"title"]];
  29. }
  30. - (void)initUI{
  31. [self addSubview:self.imageView];
  32. [self addSubview:self.title];
  33. [self addSubview:self.action];
  34. }
  35. - (void)loadLayout{
  36. [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.width.height.mas_equalTo(WHScreenEqualWidth(24));
  38. make.centerX.equalTo(self);
  39. make.top.equalTo(self).offset(WHScreenEqualWidth(17));
  40. }];
  41. [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.centerX.equalTo(self);
  43. make.top.equalTo(self.imageView.mas_bottom).offset(WHScreenEqualWidth(8));
  44. make.height.mas_equalTo(WHScreenEqualWidth(17));
  45. }];
  46. [self.action mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.edges.equalTo(self);
  48. }];
  49. }
  50. #pragma mark - get set
  51. //UIImageView *imageView;
  52. - (UIImageView *)imageView{
  53. if(!_imageView){
  54. _imageView = [[UIImageView alloc] init];
  55. }
  56. return _imageView;
  57. }
  58. //UILabel *title;
  59. - (UILabel *)title{
  60. if(!_title){
  61. _title = [[UILabel alloc] init];
  62. [_title setTextColor:HexColorFromRGB(0x171A1D)];
  63. [_title setFont:[UIFont systemFontOfSize:WHScreenEqualWidth(12)]];
  64. }
  65. return _title;
  66. }
  67. //UIControl *action;
  68. - (UIControl *)action{
  69. if(!_action){
  70. _action = [[UIControl alloc] init];
  71. [_action addTarget:self action:@selector(actionEvent) forControlEvents:UIControlEventTouchUpInside];
  72. }
  73. return _action;
  74. }
  75. - (void)actionEvent{
  76. if(self.itemBlock){
  77. self.itemBlock(self.sourceDic);
  78. }
  79. }
  80. @end