线上所有马甲包模板,与《猎豆》同UI。域名zhuadd

HSQMoreMenuView.m 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // HSQMoreMenuView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/17.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "HSQMoreMenuView.h"
  9. @interface HSQMoreMenuView (){
  10. NSArray *_buttons;
  11. NSString *_title;
  12. }
  13. @end
  14. @implementation HSQMoreMenuView
  15. - (instancetype)initWithFrame:(CGRect)frame buttonInfoArray:(NSArray *)array title:(NSString *)title{
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. _title = title;
  19. _buttons = array;
  20. self.backgroundColor = [UIColor whiteColor];
  21. self.layer.cornerRadius = 6;
  22. self.layer.masksToBounds = YES;
  23. [self initSubViews];
  24. }
  25. return self;
  26. }
  27. - (void)initSubViews {
  28. // NSArray *titles = @[@"我的粉丝",@"我的收藏",@"绑定邀请码",@"邀请好友",@"新手指南",@"用户反馈",@"五星好评",@"设置"];
  29. UILabel *titleLb = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 200, Fitsize(36))];
  30. titleLb.font = [UIFont systemFontOfSize:Fitsize(14)];
  31. titleLb.textColor = [UIColor YHColorWithHex:0x000000];
  32. titleLb.text = _title;
  33. [self addSubview:titleLb];
  34. UILabel *Line = [[UILabel alloc] initWithFrame:CGRectMake(5, titleLb.bottom, self.width-10, 1)];
  35. Line.backgroundColor = [UIColor yhGrayColor];
  36. [self addSubview:Line];
  37. CGFloat width = self.width/4;
  38. CGFloat height = width;
  39. for (int i = 0; i < _buttons.count; i++) {
  40. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(width * (i%4),Line.bottom+ (i/4)*height, width, height)];
  41. NSDictionary *dict = _buttons[i];
  42. [button setTitle:dict[@"title"] forState:UIControlStateNormal];
  43. [button setImage:[UIImage imageNamed:dict[@"image"]] forState:UIControlStateNormal];
  44. [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  45. [button setTitleColor:[UIColor YHColorWithHex:0x7c7c7c] forState:UIControlStateNormal];
  46. button.titleLabel.font = [UIFont systemFontOfSize:12];
  47. button.tag = 10000 + i;
  48. [button setButtonImageTitleStyle:ButtonImageTitleStyleTop padding:10];
  49. [self addSubview:button];
  50. }
  51. NSInteger row = _buttons.count/4;
  52. if (_buttons.count%4 != 0) {
  53. row += 1;
  54. }
  55. self.height = Line.bottom + row * height;
  56. }
  57. - (void)buttonAction:(UIButton *)sender {
  58. if (self.delelgate && [self.delelgate respondsToSelector:@selector(morenMenu:Button:clickIndex:)]) {
  59. [self.delelgate morenMenu:self Button:sender clickIndex:sender.tag-10000];
  60. }
  61. }
  62. - (UIButton *)getButtonWithIndex:(NSInteger)index {
  63. UIButton *button = [self viewWithTag:10000+index];
  64. return button;
  65. }
  66. @end