This commit is contained in:
lianxiang
2018-10-12 09:12:54 +08:00
parent dc1b1e330f
commit 97af177b88
37 changed files with 583 additions and 173 deletions
@@ -237,12 +237,15 @@
if (index > _currentModel.answerList.count) {
return;
}
//答案整型非范围 设计稿范围展示!!
NSLog(@"答案下标:%d",index);
//修改答案默认下标
//返回时查看之前选中答案时使用
_currentModel.slidervalue = value;
//选中记录 修改答案默认下标 最终答案选择根据defaultFlag 1 时为选中答案
[self changeAnswerDefaultflag:index];
}
@@ -330,8 +333,6 @@
-(void)reloadViews{
//刷新问题相关数据
if (_page == self.questonArray.count) {
NSAttributedString *nextTitle = [[NSAttributedString alloc] initWithString:@"完成" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTBOLD size:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
@@ -20,6 +20,7 @@
#import "UIButton+WebCache.h"
#import "UIImageView+WebCache.h"
#import "GiGaUserInfoVC.h"
#import "LXCustomActionSheet.h"
@interface MaskTestResultVC ()
@@ -314,26 +315,48 @@
[self showFinalShareView];
UIImage *image = [UIImage saveNavsuitImage:self.tableView];
//[[GiGaFileNanager shareInstance] saveImaeToAlBum:image];
[self jxt_showActionSheetWithTitle:@"分享到微信" message:@"" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
// [self jxt_showActionSheetWithTitle:@"分享到微信" message:@"" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
//
// alertMaker.addActionDefaultTitle(@"微信好友");
// alertMaker.addActionDefaultTitle(@"朋友圈");
// alertMaker.addActionCancelTitle(@"取消");
// } actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
// [self hidSomeViews];
// if (buttonIndex==0) {
// //好友
// [self shareImagToWX:image scene:WXSceneSession];
//
//
// }else if (buttonIndex==1){
// // 朋友圈
// [self shareImagToWX:image scene:WXSceneTimeline];
// }else{
// GILog(@"取消");
//
// }
// }];
LXCustomActionSheet *sheet = [[LXCustomActionSheet alloc] initWithTitle:@"分享到微信" optionsArr:@[@"微信好友",@"朋友圈"] cancelTitle:@"取消" selectedBlock:^(NSInteger index) {
alertMaker.addActionDefaultTitle(@"微信好友");
alertMaker.addActionDefaultTitle(@"朋友圈");
alertMaker.addActionCancelTitle(@"取消");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (index==0) {
[self hidSomeViews];
//好友
[self shareImagToWX:image scene:WXSceneSession];
}else if (index==1){
[self hidSomeViews];
// 朋友圈
[self shareImagToWX:image scene:WXSceneTimeline];
}
} cancelBlock:^{
[self hidSomeViews];
if (buttonIndex==0) {
//好友
[self shareImagToWX:image scene:WXSceneSession];
}else if (buttonIndex==1){
// 朋友圈
[self shareImagToWX:image scene:WXSceneTimeline];
}else{
GILog(@"取消");
}
GILog(@"取消");
}];
[sheet show];
}
-(void)hidSomeViews{
MaskResultShareViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
@@ -350,8 +373,7 @@
cell.shareBtn.hidden = YES;
cell.lastLabe.text = @"长按扫描二维码,测试你的肤质";
self.tabheader.hidden = NO;
}
-(void)shareImagToWX:(UIImage *)image scene:(int)scene{
@@ -17,5 +17,7 @@
@property (nonatomic,assign) int answer_id;
//默认答案 1选中 0 非选中
@property (nonatomic,assign) int defaultFlag;
//答案h序号
@property (nonatomic,assign) int sortNum;
@end
@@ -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;
}