123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- //
- // WHMineBottomView.m
- // MSYOUPAI
- //
- // Created by 刘必果 on 2024/2/1.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "WHMineBottomView.h"
- @implementation WHMineBottomView
- - (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));
- }];
-
- self.array = [NSMutableArray array];
-
- [self.array addObject:@{
- @"image":[UIImage imageNamed:@"mine_gerenzhuye"],
- @"title":@"个人主页",
- @"type":@"home",
- }];
-
- [self.array addObject:@{
- @"image":[UIImage imageNamed:@"mine_service"],
- @"title":@"在线客服",
- @"type":@"server",
- }];
-
- [self.array addObject:@{
- @"image":[UIImage imageNamed:@"mine_pingtai"],
- @"title":@"合作洽谈",
- @"type":@"cooperate",
- }];
-
- [self.array addObject:@{
- @"image":[UIImage imageNamed:@"mine_system_setting"],
- @"title":@"系统设置",
- @"type":@"setting",
- }];
-
- [self fullSource];
-
- }
- return self;
- }
- - (void)fullSource{
-
- for (UIView *item in [self.stackView arrangedSubviews]) {
- [self.stackView removeArrangedSubview:item];
- [item removeFromSuperview];
- }
-
- for (NSDictionary *dict in self.array) {
- WHMineBottomItemView *view = [[WHMineBottomItemView alloc] init];
- view.sourceDic = dict;
- [self.stackView addArrangedSubview:view];
- __weak typeof(self) weakSelf = self;
- view.itemBlock = ^(NSDictionary * _Nonnull sourceDic) {
- if(weakSelf.actionBlock){
- weakSelf.actionBlock(sourceDic);
- }
- };
- }
- }
- - (void)initUI{
- [self addSubview:self.stackView];
- }
- - (void)loadLayout{
- [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- }];
- }
- #pragma mark - get set
- - (UIStackView *)stackView{
- if(!_stackView){
- _stackView = [[UIStackView alloc] init];
- [_stackView setAxis:(UILayoutConstraintAxisHorizontal)]; //垂直布局
- // UIStackViewDistributionEqualCentering;
- // UIStackViewDistribution
- // [_stackView setSpacing:0];
- _stackView.distribution = UIStackViewDistributionEqualCentering;
- [_stackView setBackgroundColor:[UIColor whiteColor]];
- [_stackView.layer setCornerRadius:WHScreenEqualWidth(8)];
- [_stackView.layer setMasksToBounds:YES];
- _stackView.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.6f].CGColor;
- // [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.0600].CGColor;
- _stackView.layer.shadowOffset = CGSizeMake(0,2);
- _stackView.layer.shadowOpacity = 1;
- _stackView.layer.shadowRadius = 4;
- }
- return _stackView;
- }
- @end
|