ULGView.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // ULGView.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 2016/12/10.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "ULGView.h"
  9. #import "AppleIDManager.h"
  10. @implementation ULGView
  11. - (id)initWithFrame:(CGRect)frame Array:(NSArray *)array
  12. {
  13. self = [super initWithFrame:frame];
  14. if (self)
  15. {
  16. [self creatViewWithArray:array];
  17. }
  18. return self;
  19. }
  20. - (void)creatViewWithArray:(NSArray *)array
  21. {
  22. CGFloat Width = (kScreenW - array.count*47)/(array.count+1);
  23. for (int i = 0; i < array.count; i ++)
  24. {
  25. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  26. //[button setImage:[UIImage imageNamed:array[i]] forState:UIControlStateNormal];
  27. [self creatButtonViewWithButton:button andCount:[array[i] intValue]];
  28. button.frame =CGRectMake((Width+47)*i+Width, 0, 47, 47);
  29. button.tag = 100+[array[i] intValue];
  30. [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  31. button.layer.cornerRadius = button.frame.size.width/2;
  32. // manager.window = [UIApplication sharedApplication].keyWindow;
  33. [self addSubview:button];
  34. }
  35. }
  36. - (void)creatButtonViewWithButton:(UIButton *)button andCount:(int)count
  37. {
  38. switch (count)
  39. {
  40. case 1:
  41. [button setImage:[UIImage imageNamed:@"lg_qq"] forState:UIControlStateNormal];
  42. break;
  43. case 2:
  44. [button setImage:[UIImage imageNamed:@"lg_weixin"] forState:UIControlStateNormal];
  45. break;
  46. case 3:
  47. [button setImage:[UIImage imageNamed:@"lg_xinlangweibo"] forState:UIControlStateNormal];
  48. break;
  49. case 4:
  50. [button setImage:[UIImage imageNamed:@"lg_shouji"] forState:UIControlStateNormal];
  51. break;
  52. case 5:
  53. [button setImage:[UIImage imageNamed:@"icon_login_fb"] forState:UIControlStateNormal];
  54. break;
  55. case 6:
  56. [button setImage:[UIImage imageNamed:@"icon_login_fb"] forState:UIControlStateNormal];
  57. break;
  58. case 8:
  59. [button setImage:[UIImage imageNamed:@"icon_login_fb"] forState:UIControlStateNormal];
  60. break;
  61. default:
  62. break;
  63. }
  64. }
  65. - (void)buttonClick:(UIButton *)button
  66. {
  67. if (self.LDelegate)
  68. {
  69. if ([self.LDelegate respondsToSelector:@selector(enterLoginWithCount:)])
  70. {
  71. [self.LDelegate enterLoginWithCount:(int)(button.tag-100)];
  72. }
  73. }
  74. }
  75. @end