123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- //
- // ExerciseSetting.m
- // jiaPei
- //
- // Created by apple on 16/1/6.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "ExerciseSetting.h"
- @implementation ExerciseSetting
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- -(instancetype)initWithCustomFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self)
- {
- self.backgroundColor = backGroundColor;
- CGFloat kHight = (self.frame.size.height - 5)/6.0;
- CGFloat kWidth = self.frame.size.width;
-
- #pragma mark label 设置
- NSArray *labelArray = @[@"设置",@"是否自动跳转到下一题",@"是否默认展开设置",@"是否开启提示声音",@"是否切换夜间模式",@"字体大小"];
- _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 40, kHight - 10)];
- _titleLabel.text = labelArray[0];
- _titleLabel.textColor = kTitleColor;
- _titleLabel.font = [UIFont scaleSize:20];
- [self addSubview:_titleLabel];
-
- _skipLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, kHight + 5, 180, kHight - 10)];
- _skipLabel.text = labelArray[1];
- _skipLabel.textColor = contentTextColor;
- _skipLabel.font = [UIFont scaleSize:17];
- [self addSubview:_skipLabel];
-
- _explainLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 2*kHight + 5, 180, kHight - 10)];
- _explainLabel.text = labelArray[2];
- _explainLabel.textColor = contentTextColor;
- _explainLabel.font = [UIFont scaleSize:17];
- [self addSubview:_explainLabel];
-
- _voiceLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 3*kHight + 5, 180, kHight - 10)];
- _voiceLabel.text = labelArray[3];
- _voiceLabel.textColor = contentTextColor;
- _voiceLabel.font = [UIFont scaleSize:17];
- [self addSubview:_voiceLabel];
-
- _nightModel = [[UILabel alloc] initWithFrame:CGRectMake(40, 4*kHight + 5, 180, kHight - 10)];
- _nightModel.text = labelArray[4];
- _nightModel.textColor = contentTextColor;
- _nightModel.font = [UIFont scaleSize:17];
- [self addSubview:_nightModel];
-
- _fontModel = [[UILabel alloc] initWithFrame:CGRectMake(40, 5*kHight + 5, 80, kHight - 10)];
- _fontModel.text = labelArray[5];
- _fontModel.textColor = contentTextColor;
- _fontModel.font = [UIFont scaleSize:17];
- [self addSubview:_fontModel];
-
- #pragma mark imageView
- NSArray *images = @[@"settingImg01",@"settingImg02",@"settingImg03",@"settingImg04",@"settingImg05"];
- NSMutableArray *imageViews = [NSMutableArray array];
- for (int i = 0; i < 5; i ++)
- {
- UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, (i+1)*kHight + (kHight - 30)/2, 30, 30)];
- //UIViewContentModeScaleAspectFit
- [imageView setContentMode:UIViewContentModeScaleAspectFill];
- [imageView setImage:[UIImage imageNamed:images[i]]];
- //[imageView setBackgroundColor:[UIColor redColor]];
- //设置没用
- //[imageView setTintColor:contentTextColor];
- [self addSubview:imageView];
- [imageViews addObject:imageView];
- }
- _skipView = imageViews[0];
- _explainView = imageViews[1];
- _voiceView = imageViews[2];
- _nightView = imageViews[3];
- _fontView = imageViews[4];
-
- #pragma mark btn
- _finishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_finishBtn setFrame:CGRectMake(kWidth - 60, 0, 60, kHight)];
- [_finishBtn setTitle:@"完成" forState:UIControlStateNormal];
- [_finishBtn setTitleColor:defGreen forState:UIControlStateNormal];
- [self addSubview:_finishBtn];
-
- NSArray *btnTitle = @[@"+",@"-"];
- //NSArray *btnFont = @[@"14",@"16",@"20"];
- NSMutableArray *btns = [NSMutableArray array];
- CGFloat width = kSize.width - 2*kHight - 40;
- for (int i = 0; i < 2; i++)
- {
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(width + kHight/2.0 + i*1.5*kHight, 5*kHight + kHight/4.0, kHight/2.0, kHight/2.0);
- [btn setTitle:btnTitle[i] forState:UIControlStateNormal];
- [btn setTitleColor:defGreen forState:UIControlStateHighlighted];
- [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
- //[btnFont[i] floatValue]
- [btn borderColor:defGreen width:1.1 cornorRadios:kHight/4.0];
- [self addSubview:btn];
- [btns addObject:btn];
- }
- _bigBtn = btns[0];
- _smallBtn = btns[1];
-
- //夹杂一个label 要根据按钮位置添加
- _fontLabel = [[UILabel alloc] initWithFrame:CGRectMake(width + kHight, 5*kHight, kHight, kHight)];
-
- if (myDelegate.optionFont < 14 || myDelegate.optionFont > 28) {
- //默认值
- myDelegate.optionFont = 17;
- }
- _fontLabel.text = [NSString stringWithFormat:@"%d",(int)myDelegate.optionFont];
- _fontLabel.textAlignment = NSTextAlignmentCenter;
- _fontLabel.textColor = contentTextColor;
- _fontLabel.font = [UIFont scaleSize:21];
- [self addSubview:_fontLabel];
-
- #pragma mark switch
- NSMutableArray *switchs = [NSMutableArray array];
- for (int i = 0; i < 4; i++)
- {
- UISwitch *aswitch = [[UISwitch alloc] initWithFrame:CGRectMake(kWidth - 60, kHight * (i+1) +8, 50, kHight - 16)];
- [aswitch setOn:YES animated:NO];
- [self addSubview:aswitch];
- [switchs addObject:aswitch];
- }
- _skipSwitch = switchs[0];
- _explainSwitch = switchs[1];
- _voiceSwitch = switchs[2];
- _nightSwitch = switchs[3];
- [_nightSwitch setOn:NO];
-
- }
- return self;
- }
- -(instancetype)initWithExamFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self)
- {
- self.backgroundColor = backGroundColor;
- CGFloat kHight = (self.frame.size.height - 5)/4.0;
- CGFloat kWidth = self.frame.size.width;
- #pragma mark label 设置
- NSArray *labelArray = @[@"设置",@"是否开启提示声音",@"是否切换夜间模式",@"字体大小"];
- _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 40, kHight - 10)];
- _titleLabel.text = labelArray[0];
- _titleLabel.textColor = kTitleColor;
- _titleLabel.font = [UIFont scaleSize:20];
- [self addSubview:_titleLabel];
-
- _voiceLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 1*kHight + 5, 180, kHight - 10)];
- _voiceLabel.text = labelArray[1];
- _voiceLabel.textColor = contentTextColor;
- _voiceLabel.font = [UIFont scaleSize:17];
- [self addSubview:_voiceLabel];
-
- _nightModel = [[UILabel alloc] initWithFrame:CGRectMake(40, 2*kHight + 5, 180, kHight - 10)];
- _nightModel.text = labelArray[2];
- _nightModel.textColor = contentTextColor;
- _nightModel.font = [UIFont scaleSize:17];
- [self addSubview:_nightModel];
-
- _fontModel = [[UILabel alloc] initWithFrame:CGRectMake(40, 3*kHight + 5, 80, kHight - 10)];
- _fontModel.text = labelArray[3];
- _fontModel.textColor = contentTextColor;
- _fontModel.font = [UIFont scaleSize:17];
- [self addSubview:_fontModel];
-
- #pragma mark imageView
- NSArray *images = @[@"settingImg03",@"settingImg04",@"settingImg05"];
- NSMutableArray *imageViews = [NSMutableArray array];
- for (int i = 0; i < 3; i ++)
- {
- UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, (i+1)*kHight + (kHight - 30)/2, 30, 30)];
- [imageView setContentMode:UIViewContentModeScaleAspectFill];
- [imageView setImage:[UIImage imageNamed:images[i]]];
- //[imageView setBackgroundColor:[UIColor redColor]];
- [imageView setTintColor:contentTextColor];
- [self addSubview:imageView];
- [imageViews addObject:imageView];
- }
- _voiceView = imageViews[0];
- _nightView = imageViews[1];
- _fontView = imageViews[2];
-
-
- #pragma mark btn
- _finishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_finishBtn setFrame:CGRectMake(kWidth - 60, 0, 60, kHight)];
- [_finishBtn setTitle:@"完成" forState:UIControlStateNormal];
- [_finishBtn setTitleColor:defGreen forState:UIControlStateNormal];
- [self addSubview:_finishBtn];
-
- NSArray *btnTitle = @[@"+",@"-"];
- NSMutableArray *btns = [NSMutableArray array];
- CGFloat width = kSize.width - 2*kHight - 40;
- for (int i = 0; i < 2; i++)
- {
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(width + kHight/2.0 + i*1.5*kHight, 3*kHight + kHight/4.0, kHight/2.0, kHight/2.0);
- [btn setTitle:btnTitle[i] forState:UIControlStateNormal];
- [btn setTitleColor:defGreen forState:UIControlStateHighlighted];
- [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
- [btn borderColor:defGreen width:1.1 cornorRadios:kHight/4.0];
- [self addSubview:btn];
- [btns addObject:btn];
- }
- _bigBtn = btns[0];
- _smallBtn = btns[1];
-
- //夹杂一个label 要根据按钮位置添加
- _fontLabel = [[UILabel alloc] initWithFrame:CGRectMake(width + kHight, 3*kHight, kHight, kHight)];
-
- if (myDelegate.optionFont < 14 || myDelegate.optionFont > 28) {
- //默认值
- myDelegate.optionFont = 17;
- }
- _fontLabel.text = [NSString stringWithFormat:@"%d",(int)myDelegate.optionFont];
- _fontLabel.textAlignment = NSTextAlignmentCenter;
- _fontLabel.textColor = contentTextColor;
- _fontLabel.font = [UIFont scaleSize:21];
- [self addSubview:_fontLabel];
-
- #pragma mark switch
- NSMutableArray *switchs = [NSMutableArray array];
- for (int i = 0; i < 2; i++)
- {
- UISwitch *aswitch = [[UISwitch alloc] initWithFrame:CGRectMake(kWidth - 55, kHight * (i+1) +5, 50, kHight - 10)];
- [aswitch setOn:YES animated:YES];
- [self addSubview:aswitch];
- [switchs addObject:aswitch];
- }
- _voiceSwitch = switchs[0];
- _nightSwitch = switchs[1];
- [_nightSwitch setOn:NO];
- }
- return self;
- }
- @end
|