122 lines
3.2 KiB
Objective-C
122 lines
3.2 KiB
Objective-C
//
|
|
// MaskQuestionView.m
|
|
// GIGA
|
|
//
|
|
// Created by lianxiang on 2018/9/11.
|
|
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
|
//
|
|
|
|
#import "MaskQuestionView.h"
|
|
#import "GIGaQuestionSlider.h"
|
|
#import "GiGaAnswerViewCell.h"
|
|
|
|
@interface MaskQuestionView()<UITableViewDelegate,UITableViewDataSource>
|
|
@property(nonatomic,strong) NSArray *dataArr;
|
|
@property(nonatomic,strong) UITableView *tableView;
|
|
@property(nonatomic,strong) GIGaQuestionSlider *slider;
|
|
@end
|
|
|
|
@implementation MaskQuestionView
|
|
-(NSArray *)dataArr
|
|
{
|
|
if (!_dataArr) {
|
|
_dataArr = [NSArray new];
|
|
}
|
|
return _dataArr;
|
|
|
|
}
|
|
|
|
-(instancetype)initQuestionView:(CGRect)frame style:(MaskQuetionViewStyle)style titles:(NSArray *)titles{
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
if (self) {
|
|
self.dataArr = titles;
|
|
[self creatSubs:style titles:titles];
|
|
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)creatSubs:(MaskQuetionViewStyle)style titles:(NSArray *)titles{
|
|
switch (style) {
|
|
|
|
case MaskQuetionViewStleSliderNormal:
|
|
{
|
|
[self creatNormalStyle:titles];
|
|
}
|
|
break;
|
|
|
|
case MaskQuetionViewStleSliderGradient:
|
|
{
|
|
|
|
}
|
|
break;
|
|
|
|
case MaskQuetionViewStleYesOrNO:
|
|
{
|
|
|
|
}
|
|
break;
|
|
default:
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
-(void)creatNormalStyle:(NSArray *)titles{
|
|
|
|
[self creatTab];
|
|
GIGaQuestionSlider *slider = [[GIGaQuestionSlider alloc] initWithFrame:CGRectMake(0,self.frame.size.height,self.frame.size.height, 13) type:GIGaQuestionSliderTypeGray];
|
|
[slider addTarget:self action:@selector(updateValue:) forControlEvents:UIControlEventValueChanged];
|
|
self.slider = slider;
|
|
[self addSubview:slider];
|
|
self.slider.transform = CGAffineTransformMakeRotation(- M_PI/2);
|
|
}
|
|
|
|
-(void)layoutSubviews{
|
|
|
|
[super layoutSubviews];
|
|
self.slider.frame = CGRectMake(90, 0, self.slider.frame.size.width, self.frame.size.height);
|
|
|
|
}
|
|
|
|
-(void)updateValue:(UISlider *)slider{
|
|
NSLog(@"value%f",slider.value);
|
|
GILog(@"formatvalue:%.2f",slider.value*60);
|
|
|
|
}
|
|
|
|
-(void)creatTab{
|
|
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(127,0, self.frame.size.width - 127, self.frame.size.height) style:UITableViewStylePlain];
|
|
self.tableView.delegate = self;
|
|
self.tableView.dataSource = self;
|
|
self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
|
|
self.tableView.scrollEnabled = NO;
|
|
[self addSubview:self.tableView];
|
|
|
|
}
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
return self.dataArr.count;
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
return (self.frame.size.height - 20) / (self.dataArr.count -1);
|
|
|
|
}
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
GiGaAnswerViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaAnswerViewCell"];
|
|
if (!cell) {
|
|
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaAnswerViewCell" owner:self options:nil] lastObject];
|
|
}
|
|
cell.answerTitle.text =self.dataArr[indexPath.row];
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
|
@end
|