JXSelThemeColorsVC.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // JXSelThemeColorsVC.m
  3. // shiku_im
  4. //
  5. // Created by p on 2017/8/26.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "JXSelThemeColorsVC.h"
  9. @interface JXSelThemeColorsVC ()
  10. @property (nonatomic, strong) UIView *baseView;
  11. @end
  12. @implementation JXSelThemeColorsVC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.heightHeader = JX_SCREEN_TOP;
  16. self.heightFooter = 0;
  17. self.isGotoBack = YES;
  18. [self createHeadAndFoot];
  19. self.title = @"主题颜色";
  20. UILabel *tintLab = [[UILabel alloc] initWithFrame:CGRectMake(15, 11, 160, 10)];
  21. tintLab.text = @"来挑选符合你眼缘的颜色吧";
  22. tintLab.textColor = HEXCOLOR(0x999999);
  23. tintLab.font = SYSFONT(13);
  24. [self.tableBody addSubview:tintLab];
  25. self.baseView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(tintLab.frame)+5, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT - CGRectGetMaxY(tintLab.frame)-JX_SCREEN_TOP)];
  26. [self.tableBody addSubview:self.baseView];
  27. [self setupColorViews];
  28. //保存按钮
  29. UIButton *resaveBtn = [[UIButton alloc] init];
  30. resaveBtn.frame = CGRectMake(JX_SCREEN_WIDTH - 51 - 15, JX_SCREEN_TOP - 8 - 29, 51, 29);
  31. resaveBtn.custom_acceptEventInterval = 1.0f;
  32. resaveBtn.layer.masksToBounds = YES;
  33. resaveBtn.layer.cornerRadius = 3.f;
  34. [resaveBtn setBackgroundColor:THEMECOLOR];
  35. [resaveBtn.titleLabel setFont:SYSFONT(15)];
  36. [resaveBtn setTitle:Localized(@"JX_Confirm") forState:UIControlStateNormal];
  37. [resaveBtn addTarget:self action:@selector(confirmBtnAction) forControlEvents:UIControlEventTouchUpInside];
  38. [self.tableHeader addSubview:resaveBtn];
  39. }
  40. - (void) confirmBtnAction {
  41. [g_App showAlert:Localized(@"JXTheme_confirm") delegate:self tag:4444 onlyConfirm:NO];
  42. }
  43. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  44. if (alertView.tag == 4444 && buttonIndex == 1) {
  45. [g_theme switchSkinIndex:self.selectIndex];
  46. [g_mainVC.view removeFromSuperview];
  47. g_mainVC = nil;
  48. [self.view removeFromSuperview];
  49. self.view = nil;
  50. g_navigation.lastVC = nil;
  51. [g_navigation.subViews removeAllObjects];
  52. [g_App showMainUI];
  53. }
  54. }
  55. - (void)didReceiveMemoryWarning {
  56. [super didReceiveMemoryWarning];
  57. // Dispose of any resources that can be recreated.
  58. }
  59. - (void)onSelectorColor:(UIButton *)button {
  60. self.selectIndex = button.tag;
  61. for (UIView *view in self.baseView.subviews) {
  62. [view removeFromSuperview];
  63. }
  64. [self setupColorViews];
  65. }
  66. - (void)setupColorViews {
  67. UIButton *btn;
  68. int inset = 8;
  69. CGFloat w = (JX_SCREEN_WIDTH-30 - inset*3)/4;
  70. for (int i = 0; i < self.array.count; i++) {
  71. CGFloat x = 15+(w+inset)*(i % 4);
  72. int m = i / 4;
  73. btn = [self creatButtonWithFrame:CGRectMake(x, m*173+(15 * (m +1)), w, 157) color:[g_theme.skinList[i] objectForKey:SkinDictKeyColor] title:self.array[i] index:i];
  74. }
  75. }
  76. - (UIButton *)creatButtonWithFrame:(CGRect)frame color:(UIColor *)color title:(NSString *)title index:(NSInteger)index {
  77. UIButton *view = [[UIButton alloc] initWithFrame:frame];
  78. view.tag = index;
  79. [view addTarget:self action:@selector(onSelectorColor:) forControlEvents:UIControlEventTouchUpInside];
  80. [self.baseView addSubview:view];
  81. UIView *colorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 133)];
  82. colorView.backgroundColor = color;
  83. colorView.layer.masksToBounds = YES;
  84. colorView.layer.cornerRadius = 7.f;
  85. colorView.userInteractionEnabled = NO;
  86. [view addSubview:colorView];
  87. UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width-5-14, 7, 14, 14)];
  88. imgV.image = [UIImage imageNamed:@"ThemeColor"];
  89. imgV.hidden = index != self.selectIndex;
  90. [colorView addSubview:imgV];
  91. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(colorView.frame)+10, frame.size.width, 14)];
  92. label.text = title;
  93. label.textAlignment = NSTextAlignmentCenter;
  94. label.textColor = HEXCOLOR(0x333333);
  95. label.font = SYSFONT(14);
  96. [view addSubview:label];
  97. return view;
  98. }
  99. /*
  100. #pragma mark - Navigation
  101. // In a storyboard-based application, you will often want to do a little preparation before navigation
  102. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  103. // Get the new view controller using [segue destinationViewController].
  104. // Pass the selected object to the new view controller.
  105. }
  106. */
  107. @end