WHMineBottomView.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // WHMineBottomView.m
  3. // MSYOUPAI
  4. //
  5. // Created by 刘必果 on 2024/2/1.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "WHMineBottomView.h"
  9. @implementation WHMineBottomView
  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. }];
  21. self.array = [NSMutableArray array];
  22. [self.array addObject:@{
  23. @"image":[UIImage imageNamed:@"mine_gerenzhuye"],
  24. @"title":@"个人主页",
  25. @"type":@"home",
  26. }];
  27. [self.array addObject:@{
  28. @"image":[UIImage imageNamed:@"mine_service"],
  29. @"title":@"在线客服",
  30. @"type":@"server",
  31. }];
  32. [self.array addObject:@{
  33. @"image":[UIImage imageNamed:@"mine_pingtai"],
  34. @"title":@"合作洽谈",
  35. @"type":@"cooperate",
  36. }];
  37. [self.array addObject:@{
  38. @"image":[UIImage imageNamed:@"mine_system_setting"],
  39. @"title":@"系统设置",
  40. @"type":@"setting",
  41. }];
  42. [self fullSource];
  43. }
  44. return self;
  45. }
  46. - (void)fullSource{
  47. for (UIView *item in [self.stackView arrangedSubviews]) {
  48. [self.stackView removeArrangedSubview:item];
  49. [item removeFromSuperview];
  50. }
  51. for (NSDictionary *dict in self.array) {
  52. WHMineBottomItemView *view = [[WHMineBottomItemView alloc] init];
  53. view.sourceDic = dict;
  54. [self.stackView addArrangedSubview:view];
  55. __weak typeof(self) weakSelf = self;
  56. view.itemBlock = ^(NSDictionary * _Nonnull sourceDic) {
  57. if(weakSelf.actionBlock){
  58. weakSelf.actionBlock(sourceDic);
  59. }
  60. };
  61. }
  62. }
  63. - (void)initUI{
  64. [self addSubview:self.stackView];
  65. }
  66. - (void)loadLayout{
  67. [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.edges.equalTo(self);
  69. }];
  70. }
  71. #pragma mark - get set
  72. - (UIStackView *)stackView{
  73. if(!_stackView){
  74. _stackView = [[UIStackView alloc] init];
  75. [_stackView setAxis:(UILayoutConstraintAxisHorizontal)]; //垂直布局
  76. // UIStackViewDistributionEqualCentering;
  77. // UIStackViewDistribution
  78. // [_stackView setSpacing:0];
  79. _stackView.distribution = UIStackViewDistributionEqualCentering;
  80. [_stackView setBackgroundColor:[UIColor whiteColor]];
  81. [_stackView.layer setCornerRadius:WHScreenEqualWidth(8)];
  82. [_stackView.layer setMasksToBounds:YES];
  83. _stackView.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.6f].CGColor;
  84. // [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.0600].CGColor;
  85. _stackView.layer.shadowOffset = CGSizeMake(0,2);
  86. _stackView.layer.shadowOpacity = 1;
  87. _stackView.layer.shadowRadius = 4;
  88. }
  89. return _stackView;
  90. }
  91. @end