ExerciseSetting.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. //
  2. // ExerciseSetting.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/1/6.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "ExerciseSetting.h"
  9. @implementation ExerciseSetting
  10. /*
  11. // Only override drawRect: if you perform custom drawing.
  12. // An empty implementation adversely affects performance during animation.
  13. - (void)drawRect:(CGRect)rect {
  14. // Drawing code
  15. }
  16. */
  17. -(instancetype)initWithCustomFrame:(CGRect)frame
  18. {
  19. self = [super initWithFrame:frame];
  20. if (self)
  21. {
  22. self.backgroundColor = backGroundColor;
  23. CGFloat kHight = (self.frame.size.height - 5)/6.0;
  24. CGFloat kWidth = self.frame.size.width;
  25. #pragma mark label 设置
  26. NSArray *labelArray = @[@"设置",@"是否自动跳转到下一题",@"是否默认展开设置",@"是否开启提示声音",@"是否切换夜间模式",@"字体大小"];
  27. _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 40, kHight - 10)];
  28. _titleLabel.text = labelArray[0];
  29. _titleLabel.textColor = kTitleColor;
  30. _titleLabel.font = [UIFont scaleSize:20];
  31. [self addSubview:_titleLabel];
  32. _skipLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, kHight + 5, 180, kHight - 10)];
  33. _skipLabel.text = labelArray[1];
  34. _skipLabel.textColor = contentTextColor;
  35. _skipLabel.font = [UIFont scaleSize:17];
  36. [self addSubview:_skipLabel];
  37. _explainLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 2*kHight + 5, 180, kHight - 10)];
  38. _explainLabel.text = labelArray[2];
  39. _explainLabel.textColor = contentTextColor;
  40. _explainLabel.font = [UIFont scaleSize:17];
  41. [self addSubview:_explainLabel];
  42. _voiceLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 3*kHight + 5, 180, kHight - 10)];
  43. _voiceLabel.text = labelArray[3];
  44. _voiceLabel.textColor = contentTextColor;
  45. _voiceLabel.font = [UIFont scaleSize:17];
  46. [self addSubview:_voiceLabel];
  47. _nightModel = [[UILabel alloc] initWithFrame:CGRectMake(40, 4*kHight + 5, 180, kHight - 10)];
  48. _nightModel.text = labelArray[4];
  49. _nightModel.textColor = contentTextColor;
  50. _nightModel.font = [UIFont scaleSize:17];
  51. [self addSubview:_nightModel];
  52. _fontModel = [[UILabel alloc] initWithFrame:CGRectMake(40, 5*kHight + 5, 80, kHight - 10)];
  53. _fontModel.text = labelArray[5];
  54. _fontModel.textColor = contentTextColor;
  55. _fontModel.font = [UIFont scaleSize:17];
  56. [self addSubview:_fontModel];
  57. #pragma mark imageView
  58. NSArray *images = @[@"settingImg01",@"settingImg02",@"settingImg03",@"settingImg04",@"settingImg05"];
  59. NSMutableArray *imageViews = [NSMutableArray array];
  60. for (int i = 0; i < 5; i ++)
  61. {
  62. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, (i+1)*kHight + (kHight - 30)/2, 30, 30)];
  63. //UIViewContentModeScaleAspectFit
  64. [imageView setContentMode:UIViewContentModeScaleAspectFill];
  65. [imageView setImage:[UIImage imageNamed:images[i]]];
  66. //[imageView setBackgroundColor:[UIColor redColor]];
  67. //设置没用
  68. //[imageView setTintColor:contentTextColor];
  69. [self addSubview:imageView];
  70. [imageViews addObject:imageView];
  71. }
  72. _skipView = imageViews[0];
  73. _explainView = imageViews[1];
  74. _voiceView = imageViews[2];
  75. _nightView = imageViews[3];
  76. _fontView = imageViews[4];
  77. #pragma mark btn
  78. _finishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  79. [_finishBtn setFrame:CGRectMake(kWidth - 60, 0, 60, kHight)];
  80. [_finishBtn setTitle:@"完成" forState:UIControlStateNormal];
  81. [_finishBtn setTitleColor:defGreen forState:UIControlStateNormal];
  82. [self addSubview:_finishBtn];
  83. NSArray *btnTitle = @[@"+",@"-"];
  84. //NSArray *btnFont = @[@"14",@"16",@"20"];
  85. NSMutableArray *btns = [NSMutableArray array];
  86. CGFloat width = kSize.width - 2*kHight - 40;
  87. for (int i = 0; i < 2; i++)
  88. {
  89. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  90. btn.frame = CGRectMake(width + kHight/2.0 + i*1.5*kHight, 5*kHight + kHight/4.0, kHight/2.0, kHight/2.0);
  91. [btn setTitle:btnTitle[i] forState:UIControlStateNormal];
  92. [btn setTitleColor:defGreen forState:UIControlStateHighlighted];
  93. [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
  94. //[btnFont[i] floatValue]
  95. [btn borderColor:defGreen width:1.1 cornorRadios:kHight/4.0];
  96. [self addSubview:btn];
  97. [btns addObject:btn];
  98. }
  99. _bigBtn = btns[0];
  100. _smallBtn = btns[1];
  101. //夹杂一个label 要根据按钮位置添加
  102. _fontLabel = [[UILabel alloc] initWithFrame:CGRectMake(width + kHight, 5*kHight, kHight, kHight)];
  103. if (myDelegate.optionFont < 14 || myDelegate.optionFont > 28) {
  104. //默认值
  105. myDelegate.optionFont = 17;
  106. }
  107. _fontLabel.text = [NSString stringWithFormat:@"%d",(int)myDelegate.optionFont];
  108. _fontLabel.textAlignment = NSTextAlignmentCenter;
  109. _fontLabel.textColor = contentTextColor;
  110. _fontLabel.font = [UIFont scaleSize:21];
  111. [self addSubview:_fontLabel];
  112. #pragma mark switch
  113. NSMutableArray *switchs = [NSMutableArray array];
  114. for (int i = 0; i < 4; i++)
  115. {
  116. UISwitch *aswitch = [[UISwitch alloc] initWithFrame:CGRectMake(kWidth - 60, kHight * (i+1) +8, 50, kHight - 16)];
  117. [aswitch setOn:YES animated:NO];
  118. [self addSubview:aswitch];
  119. [switchs addObject:aswitch];
  120. }
  121. _skipSwitch = switchs[0];
  122. _explainSwitch = switchs[1];
  123. _voiceSwitch = switchs[2];
  124. _nightSwitch = switchs[3];
  125. [_nightSwitch setOn:NO];
  126. }
  127. return self;
  128. }
  129. -(instancetype)initWithExamFrame:(CGRect)frame
  130. {
  131. self = [super initWithFrame:frame];
  132. if (self)
  133. {
  134. self.backgroundColor = backGroundColor;
  135. CGFloat kHight = (self.frame.size.height - 5)/4.0;
  136. CGFloat kWidth = self.frame.size.width;
  137. #pragma mark label 设置
  138. NSArray *labelArray = @[@"设置",@"是否开启提示声音",@"是否切换夜间模式",@"字体大小"];
  139. _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 40, kHight - 10)];
  140. _titleLabel.text = labelArray[0];
  141. _titleLabel.textColor = kTitleColor;
  142. _titleLabel.font = [UIFont scaleSize:20];
  143. [self addSubview:_titleLabel];
  144. _voiceLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 1*kHight + 5, 180, kHight - 10)];
  145. _voiceLabel.text = labelArray[1];
  146. _voiceLabel.textColor = contentTextColor;
  147. _voiceLabel.font = [UIFont scaleSize:17];
  148. [self addSubview:_voiceLabel];
  149. _nightModel = [[UILabel alloc] initWithFrame:CGRectMake(40, 2*kHight + 5, 180, kHight - 10)];
  150. _nightModel.text = labelArray[2];
  151. _nightModel.textColor = contentTextColor;
  152. _nightModel.font = [UIFont scaleSize:17];
  153. [self addSubview:_nightModel];
  154. _fontModel = [[UILabel alloc] initWithFrame:CGRectMake(40, 3*kHight + 5, 80, kHight - 10)];
  155. _fontModel.text = labelArray[3];
  156. _fontModel.textColor = contentTextColor;
  157. _fontModel.font = [UIFont scaleSize:17];
  158. [self addSubview:_fontModel];
  159. #pragma mark imageView
  160. NSArray *images = @[@"settingImg03",@"settingImg04",@"settingImg05"];
  161. NSMutableArray *imageViews = [NSMutableArray array];
  162. for (int i = 0; i < 3; i ++)
  163. {
  164. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, (i+1)*kHight + (kHight - 30)/2, 30, 30)];
  165. [imageView setContentMode:UIViewContentModeScaleAspectFill];
  166. [imageView setImage:[UIImage imageNamed:images[i]]];
  167. //[imageView setBackgroundColor:[UIColor redColor]];
  168. [imageView setTintColor:contentTextColor];
  169. [self addSubview:imageView];
  170. [imageViews addObject:imageView];
  171. }
  172. _voiceView = imageViews[0];
  173. _nightView = imageViews[1];
  174. _fontView = imageViews[2];
  175. #pragma mark btn
  176. _finishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  177. [_finishBtn setFrame:CGRectMake(kWidth - 60, 0, 60, kHight)];
  178. [_finishBtn setTitle:@"完成" forState:UIControlStateNormal];
  179. [_finishBtn setTitleColor:defGreen forState:UIControlStateNormal];
  180. [self addSubview:_finishBtn];
  181. NSArray *btnTitle = @[@"+",@"-"];
  182. NSMutableArray *btns = [NSMutableArray array];
  183. CGFloat width = kSize.width - 2*kHight - 40;
  184. for (int i = 0; i < 2; i++)
  185. {
  186. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  187. btn.frame = CGRectMake(width + kHight/2.0 + i*1.5*kHight, 3*kHight + kHight/4.0, kHight/2.0, kHight/2.0);
  188. [btn setTitle:btnTitle[i] forState:UIControlStateNormal];
  189. [btn setTitleColor:defGreen forState:UIControlStateHighlighted];
  190. [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
  191. [btn borderColor:defGreen width:1.1 cornorRadios:kHight/4.0];
  192. [self addSubview:btn];
  193. [btns addObject:btn];
  194. }
  195. _bigBtn = btns[0];
  196. _smallBtn = btns[1];
  197. //夹杂一个label 要根据按钮位置添加
  198. _fontLabel = [[UILabel alloc] initWithFrame:CGRectMake(width + kHight, 3*kHight, kHight, kHight)];
  199. if (myDelegate.optionFont < 14 || myDelegate.optionFont > 28) {
  200. //默认值
  201. myDelegate.optionFont = 17;
  202. }
  203. _fontLabel.text = [NSString stringWithFormat:@"%d",(int)myDelegate.optionFont];
  204. _fontLabel.textAlignment = NSTextAlignmentCenter;
  205. _fontLabel.textColor = contentTextColor;
  206. _fontLabel.font = [UIFont scaleSize:21];
  207. [self addSubview:_fontLabel];
  208. #pragma mark switch
  209. NSMutableArray *switchs = [NSMutableArray array];
  210. for (int i = 0; i < 2; i++)
  211. {
  212. UISwitch *aswitch = [[UISwitch alloc] initWithFrame:CGRectMake(kWidth - 55, kHight * (i+1) +5, 50, kHight - 10)];
  213. [aswitch setOn:YES animated:YES];
  214. [self addSubview:aswitch];
  215. [switchs addObject:aswitch];
  216. }
  217. _voiceSwitch = switchs[0];
  218. _nightSwitch = switchs[1];
  219. [_nightSwitch setOn:NO];
  220. }
  221. return self;
  222. }
  223. @end