add 题目
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// GIGaQuestionSlider.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/11.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
typedef NS_ENUM(NSInteger,GIGaQuestionSliderType)
|
||||
{
|
||||
GIGaQuestionSliderTypeGray = 0,//灰
|
||||
GIGaQuestionSliderTypeGradient ,//变色
|
||||
|
||||
|
||||
};
|
||||
|
||||
@interface GIGaQuestionSlider : UISlider
|
||||
- (instancetype)initWithFrame:(CGRect)frame type:(GIGaQuestionSliderType)type;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// GIGaQuestionSlider.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/11.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GIGaQuestionSlider.h"
|
||||
#import "UIColor+HexColor.h"
|
||||
@interface GIGaQuestionSlider()
|
||||
|
||||
@end
|
||||
|
||||
@implementation GIGaQuestionSlider
|
||||
|
||||
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame type:(GIGaQuestionSliderType)type
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
|
||||
self.minimumValue = 0.0;
|
||||
self.maximumValue = 1.0;
|
||||
self.value = 0.5;
|
||||
|
||||
[self creatSubView:type];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)creatSubView:(GIGaQuestionSliderType)type{
|
||||
[self thumbimageView];
|
||||
|
||||
switch (type) {
|
||||
case GIGaQuestionSliderTypeGray:
|
||||
{
|
||||
[self createUI];
|
||||
}
|
||||
break;
|
||||
case GIGaQuestionSliderTypeGradient:
|
||||
{
|
||||
[self creatGradient];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
-(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:0x9A9996] CGColor]];
|
||||
NSArray *colorLocationArray = @[@0.0, @0.5, @1];
|
||||
CAGradientLayer * gradientLayer = [CAGradientLayer layer];
|
||||
gradientLayer.frame = self.bounds;
|
||||
gradientLayer.masksToBounds = YES;
|
||||
gradientLayer.cornerRadius = self.frame.size.height /2 ;
|
||||
gradientLayer.borderWidth = 1;
|
||||
gradientLayer.borderColor =GIGARGB(215, 215, 215, 1).CGColor;
|
||||
|
||||
[gradientLayer setLocations:colorLocationArray];
|
||||
[gradientLayer setColors:colorArr];
|
||||
[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.value = 0.5;
|
||||
self.minimumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
self.maximumTrackTintColor = GIGARGB(216,216, 216, 1);
|
||||
|
||||
}
|
||||
|
||||
-(CGRect)trackRectForBounds:(CGRect)bounds
|
||||
{
|
||||
bounds.origin.x = bounds.origin.x;
|
||||
bounds.origin.y = bounds.origin.y;
|
||||
bounds.size.height = bounds.size.height;
|
||||
bounds.size.width = bounds.size.width;
|
||||
return bounds;
|
||||
}
|
||||
|
||||
-(void)thumbimageView{
|
||||
|
||||
[self setThumbImage:[self OriginImage:[UIImage imageNamed:@"btn_slider_thumb"] scaleToSize:CGSizeMake(40, 40)] forState:UIControlStateNormal];
|
||||
[self setThumbImage:[self OriginImage:[UIImage imageNamed:@"btn_slider_thumb"] scaleToSize:CGSizeMake(40, 40)] forState:UIControlStateHighlighted];
|
||||
}
|
||||
|
||||
-(UIImage*) OriginImage:(UIImage*)image scaleToSize:(CGSize)size
|
||||
|
||||
{
|
||||
UIGraphicsBeginImageContext(size);//size为CGSize类型,即你所需要的图片尺寸
|
||||
[image drawInRect:CGRectMake(0,0, size.width, size.height)];
|
||||
|
||||
UIImage* scaledImage =UIGraphicsGetImageFromCurrentImageContext();
|
||||
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
return scaledImage;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// GiGaAnswerViewCell.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/11.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GiGaAnswerViewCell : UITableViewCell
|
||||
@property (weak, nonatomic) IBOutlet UILabel *answerTitle;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// GiGaAnswerViewCell.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/11.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GiGaAnswerViewCell.h"
|
||||
|
||||
@implementation GiGaAnswerViewCell
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="GiGaAnswerViewCell" id="KGk-i7-Jjw" customClass="GiGaAnswerViewCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lXL-TA-ugK">
|
||||
<rect key="frame" x="0.0" y="10" width="96" height="1"/>
|
||||
<color key="backgroundColor" red="0.94117647058823528" green="0.94117647058823528" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="1" id="34F-F0-EkR"/>
|
||||
<constraint firstAttribute="width" constant="96" id="AX3-TO-AIq"/>
|
||||
<constraint firstAttribute="height" constant="1" id="CAS-mG-3dd"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iR5-Lj-9dP">
|
||||
<rect key="frame" x="106" y="0.0" width="198" height="20"/>
|
||||
<fontDescription key="fontDescription" name="PingFangSC-Semibold" family="PingFang SC" pointSize="14"/>
|
||||
<color key="textColor" red="0.76470588235294112" green="0.15686274509803921" blue="0.15686274509803921" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="iR5-Lj-9dP" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="304-cd-159"/>
|
||||
<constraint firstAttribute="trailing" secondItem="iR5-Lj-9dP" secondAttribute="trailing" constant="16" id="MYZ-d5-ASU"/>
|
||||
<constraint firstItem="lXL-TA-ugK" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="10" id="dzx-Mu-xz2"/>
|
||||
<constraint firstItem="lXL-TA-ugK" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="10" id="o2d-gS-JsL"/>
|
||||
<constraint firstItem="lXL-TA-ugK" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="uJK-WQ-wVS"/>
|
||||
<constraint firstItem="iR5-Lj-9dP" firstAttribute="leading" secondItem="lXL-TA-ugK" secondAttribute="trailing" constant="10" id="x2y-To-TgM"/>
|
||||
<constraint firstItem="lXL-TA-ugK" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="yDs-SX-6eP"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
|
||||
<connections>
|
||||
<outlet property="answerTitle" destination="iR5-Lj-9dP" id="Jlc-ce-rWZ"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// MaskQuestionView.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/11.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
typedef NS_ENUM(NSInteger,MaskQuetionViewStyle)
|
||||
{
|
||||
MaskQuetionViewStleSliderNormal = 0,// 滑块正常
|
||||
MaskQuetionViewStleSliderGradient ,//滑块变色
|
||||
MaskQuetionViewStleYesOrNO // 是 否
|
||||
|
||||
};
|
||||
|
||||
@interface MaskQuestionView : UIView
|
||||
@property(nonatomic,assign) MaskQuetionViewStyle *style;
|
||||
|
||||
-(instancetype)initQuestionView:(CGRect)frame style:(MaskQuetionViewStyle)style titles:(NSArray *)titles;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// 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
|
||||
Reference in New Issue
Block a user