123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //
- // KBMoreMenuView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/17.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBMoreMenuView.h"
- @interface KBMoreMenuView (){
- NSArray *_buttons;
- }
- @end
- @implementation KBMoreMenuView
- - (instancetype)initWithFrame:(CGRect)frame buttonInfoArray:(NSArray *)array{
- self = [super initWithFrame:frame];
- if (self) {
- _buttons = array;
- self.backgroundColor = [UIColor whiteColor];
- self.layer.cornerRadius = 6;
- self.layer.masksToBounds = YES;
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- // NSArray *titles = @[@"我的粉丝",@"我的收藏",@"绑定邀请码",@"邀请好友",@"新手指南",@"用户反馈",@"五星好评",@"设置"];
- CGFloat width = self.width/4;
- CGFloat height = self.width/4;
-
- for (int i = 0; i < _buttons.count; i++) {
- UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(width * (i%4), 0, width, height)];
- NSDictionary *dict = _buttons[i];
- [button setTitle:dict[@"title"] forState:UIControlStateNormal];
- [button setImage:[UIImage imageNamed:dict[@"image"]] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
-
- [button setTitleColor:[UIColor YHColorWithHex:0x7c7c7c] forState:UIControlStateNormal];
- button.titleLabel.font = [UIFont systemFontOfSize:12];
- button.tag = 10000 + i;
-
- [button setButtonImageTitleStyle:ButtonImageTitleStyleTop padding:15];
- [self addSubview:button];
- }
- }
- - (void)buttonAction:(UIButton *)sender {
- if (self.delelgate && [self.delelgate respondsToSelector:@selector(morenMenu:Button:clickIndex:)]) {
- [self.delelgate morenMenu:self Button:sender clickIndex:sender.tag-10000];
- }
- }
- @end
|