add
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
typedef NS_ENUM(NSInteger,GIGaQuestionSliderType)
|
||||
{
|
||||
GIGaQuestionSliderTypeGray = 0,//灰
|
||||
GIGaQuestionSliderTypeGray = 0,//灰 //红
|
||||
GIGaQuestionSliderTypeGradient ,//变色
|
||||
GIGaQuestionSliderTypeIndicator //带指示器
|
||||
};
|
||||
|
||||
@@ -57,13 +57,14 @@
|
||||
}
|
||||
|
||||
-(void)creatGradient{
|
||||
|
||||
self.minimumTrackTintColor=[UIColor clearColor];
|
||||
self.maximumTrackTintColor=[UIColor clearColor];
|
||||
|
||||
NSArray *colorArr = @[(id)[[UIColor colorWithHex:0xFFFFFF] CGColor],
|
||||
(id)[[UIColor colorWithHex:0xFFF3E4] CGColor],
|
||||
(id)[[UIColor colorWithHex:0xFBC37B] CGColor]];
|
||||
NSArray *colorLocationArray = @[@0.0, @0.5, @1];
|
||||
NSArray *colorLocationArray = @[@0.0, @0.5, @1.0];
|
||||
CAGradientLayer * gradientLayer = [CAGradientLayer layer];
|
||||
gradientLayer.frame = self.bounds;
|
||||
gradientLayer.masksToBounds = YES;
|
||||
@@ -76,18 +77,21 @@
|
||||
[gradientLayer setStartPoint:CGPointMake(0, 0)];
|
||||
[gradientLayer setEndPoint:CGPointMake(1, 0)];
|
||||
[self.layer addSublayer:gradientLayer];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)createUI{
|
||||
|
||||
self.minimumValue = 0.0;
|
||||
self.maximumValue = 1.0;
|
||||
self.minimumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
self.maximumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
// self.minimumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
// self.maximumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
self.minimumTrackTintColor = GIGAUIColorFromRGBA(0xEA4D4D);
|
||||
self.maximumTrackTintColor = GIGAUIColorFromRGBA(0xEA4D4D);
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(CGRect)trackRectForBounds:(CGRect)bounds
|
||||
{
|
||||
bounds.origin.x = bounds.origin.x;
|
||||
@@ -95,6 +99,7 @@
|
||||
bounds.size.height = bounds.size.height;
|
||||
bounds.size.width = bounds.size.width;
|
||||
return bounds;
|
||||
|
||||
}
|
||||
|
||||
-(void)thumbimageView{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
@@ -49,6 +49,7 @@
|
||||
<connections>
|
||||
<outlet property="answerTitle" destination="iR5-Lj-9dP" id="Jlc-ce-rWZ"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="137.59999999999999" y="148.42578710644679"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
|
||||
@@ -80,13 +80,15 @@
|
||||
-(void)creatPopSlider{
|
||||
|
||||
[self creatTab];
|
||||
NYSliderPopover *slider = [[NYSliderPopover alloc] init];
|
||||
slider.frame = CGRectMake(0,self.frame.size.height,self.frame.size.height, 13);
|
||||
NYSliderPopover *slider = [[NYSliderPopover alloc] initWithFrame:CGRectMake(0,self.frame.size.height,self.frame.size.height, 14)];
|
||||
// slider.frame = CGRectMake(0,self.frame.size.height,self.frame.size.height, 14);
|
||||
[slider addTarget:self action:@selector(updateValue:) forControlEvents:UIControlEventValueChanged];
|
||||
self.poSlider = slider;
|
||||
self.poSlider = slider;
|
||||
[self addSubview:slider];
|
||||
//self.poSlider.value = self.currentModel.slidervalue;
|
||||
self.poSlider.value = self.currentModel.slidervalue;
|
||||
self.poSlider.transform = CGAffineTransformMakeRotation(- M_PI/2);
|
||||
//NSLog(@"popslider%@",self.poSlider);
|
||||
|
||||
}
|
||||
|
||||
-(void)creatNormalStyle:(NSArray *)titles style:(GIGaQuestionSliderType)type{
|
||||
@@ -96,12 +98,13 @@
|
||||
|
||||
-(void)creatSliderType:(GIGaQuestionSliderType)type{
|
||||
|
||||
GIGaQuestionSlider *slider = [[GIGaQuestionSlider alloc] initWithFrame:CGRectMake(0,self.frame.size.height,self.frame.size.height, 13) type:type];
|
||||
GIGaQuestionSlider *slider = [[GIGaQuestionSlider alloc] initWithFrame:CGRectMake(0,self.frame.size.height,self.frame.size.height, 14) type:type];
|
||||
[slider addTarget:self action:@selector(updateValue:) forControlEvents:UIControlEventValueChanged];
|
||||
self.slider = slider;
|
||||
[self.slider setValue:self.currentModel.slidervalue];
|
||||
[self addSubview:slider];
|
||||
self.slider.transform = CGAffineTransformMakeRotation(- M_PI/2);
|
||||
|
||||
}
|
||||
|
||||
-(void)layoutSubviews{
|
||||
@@ -145,9 +148,9 @@
|
||||
|
||||
[self selectNOBtnState:self.noBtn];
|
||||
}else{
|
||||
|
||||
[self selctYesBtnState:self.yesBtn];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 是
|
||||
@@ -192,8 +195,40 @@
|
||||
|
||||
-(void)updateValue:(UISlider *)slider{
|
||||
NSLog(@"value%f",slider.value);
|
||||
// 2 ,3 ,5 题slider 滑动时自动滑动到答案
|
||||
|
||||
if (self.poSlider) {
|
||||
//1 范围匹配取值
|
||||
[self anlysisAnswerWithSlider:slider.value];
|
||||
}else{
|
||||
// 2 ,3 ,5 题slider 滑动时自动滑动到答案
|
||||
// 范围0 ~ 100
|
||||
//每一份高度
|
||||
NSInteger totalCount = _answerList.count;
|
||||
CGFloat powSize = 100.f / (totalCount -1);
|
||||
//当前值
|
||||
CGFloat currentValue = slider.value * 100.f;
|
||||
//答案游标
|
||||
int count = currentValue / powSize;
|
||||
//最终自动滑到答案slider对应的value
|
||||
int index = 0 ;
|
||||
index = (int)_answerList.count - 1 -count;
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
NSLog(@"%d",index);
|
||||
float value = 1.f/(totalCount -1) * count;
|
||||
NSLog(@"%f",value);
|
||||
[self anlysisAnswerWithSlider:value];
|
||||
[self sliderAutoChoiceAnswerValue:value];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[self anlysisAnswerWithSlider:slider.value];
|
||||
-(void)sliderAutoChoiceAnswerValue:(float)value{
|
||||
|
||||
[self.slider setValue:value];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 题目答案解析
|
||||
@@ -228,7 +263,7 @@
|
||||
//答案游标 1开始
|
||||
int count = currentValue / powSize;
|
||||
|
||||
//答案数组下标
|
||||
//答案数组下标 与slider值逆序对应(slider 0 对应 数组最大下标)
|
||||
int index = 0 ;
|
||||
index = (int)_answerList.count - 1 -count;
|
||||
if (index < 0) {
|
||||
|
||||
@@ -23,8 +23,18 @@
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
|
||||
|
||||
[self thumbimageView];
|
||||
[self createUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self thumbimageView];
|
||||
[self createUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -34,16 +44,15 @@
|
||||
|
||||
- (NYPopover *)popover
|
||||
{
|
||||
if (_popover == nil) {
|
||||
if (_popover == nil){
|
||||
//Default size, can be changed after
|
||||
[self addTarget:self action:@selector(updatePopoverFrame) forControlEvents:UIControlEventValueChanged];
|
||||
_popover = [[NYPopover alloc] initWithFrame:CGRectMake(self.frame.origin.x, self.frame.origin.y - 32, 40, 32)];
|
||||
[self updatePopoverFrame];
|
||||
_popover.alpha = 0;
|
||||
[self.superview addSubview:_popover];
|
||||
|
||||
[self thumbimageView];
|
||||
[self createUI];
|
||||
// [self thumbimageView];
|
||||
// [self createUI];
|
||||
}
|
||||
|
||||
return _popover;
|
||||
@@ -52,7 +61,8 @@
|
||||
- (void)setValue:(float)value
|
||||
{
|
||||
[super setValue:value];
|
||||
[self updatePopoverFrame];
|
||||
//[self updatePopoverFrame];
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
@@ -157,8 +167,10 @@
|
||||
|
||||
self.minimumValue = 0.0;
|
||||
self.maximumValue = 1.0;
|
||||
self.minimumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
self.maximumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
// self.minimumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
// self.maximumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
self.minimumTrackTintColor = GIGAUIColorFromRGBA(0xEA4D4D);
|
||||
self.maximumTrackTintColor = GIGAUIColorFromRGBA(0xEA4D4D);
|
||||
|
||||
}
|
||||
|
||||
@@ -171,6 +183,8 @@
|
||||
return bounds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)thumbimageView{
|
||||
|
||||
[self setThumbImage:[self OriginImage:[UIImage imageNamed:@"btn_slider_thumb"] scaleToSize:CGSizeMake(40, 40)] forState:UIControlStateNormal];
|
||||
@@ -236,7 +250,6 @@
|
||||
if ((point.x >= _lastBounds.origin.x - thumbBound_x) && (point.x <= (_lastBounds.origin.x + _lastBounds.size.width + thumbBound_x)) && (point.y < (_lastBounds.size.height + thumbBound_y))) {
|
||||
result = YES;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user