UIProgressView
UIProgressView *progress; //進度
progress = [[UIProgressViewalloc]initWithFrame:CGRectMake(20,350,200,20)];
//進度條顏色
progress.trackTintColor = [UIColorredColor];
//進度條已經進行的進度的顏色
progress.progressTintColor = [UIColorblueColor];
//進度條的進度 添加計時器 0.1秒 更新進度 也可以設置其他 0 ~ 1之間
progress.progress =player.currentTime/player.duration;
[self.viewaddSubview:progress];
@property(nonatomic)UIProgressViewStyle progressViewStyle;
@property(nonatomic)float progress; // 0.0 .. 1.0, default is 0.0. 進度條 進度
@property(nonatomic,strong,nullable)UIColor* progressTintColor 已經走過的顏色
@property(nonatomic,strong,nullable)UIColor* trackTintColor 還沒走的顏色
@property(nonatomic,strong,nullable)UIImage* progressImage
@property(nonatomic,strong,nullable)UIImage* trackImage
- (void)setProgress:(float)progress animated:(BOOL)animatedNS_AVAILABLE_IOS(5_0);
@property(nonatomic,strong,nullable)NSProgress *observedProgressNS_AVAILABLE_IOS(9_0);更新進度
UISlider 滑動器
slider = [[UISlideralloc]initWithFrame:CGRectMake(20,370,200,20)];
slider.maximumValue =10;//最大
slider.minimumValue =0;//最小
slider.value =5; //
//可以在 下面的方法裏面修改 slider.value 當前滑動器的位置
[slideraddTarget:selfaction:@selector(sliderMethod)forControlEvents:UIControlEventValueChanged];
[self.viewaddSubview:slider];
@property(nonatomic)float value; // default 0.0. this value will be pinned to min/max 當前的值
@property(nonatomic)float minimumValue; // default 0.0. the current value may change if outside new min value 最小值
@property(nonatomic)float maximumValue; // default 1.0. the current value may change if outside new max value 最大值
@property(nullable,nonatomic,strong)UIImage *minimumValueImage; // default is nil. image that appears to left of control (e.g. speaker off)
@property(nullable,nonatomic,strong)UIImage *maximumValueImage; // default is nil. image that appears to right of control (e.g. speaker max)
@property(nonatomic,getter=isContinuous)BOOL continuous; // if set, value change events are generated any time the value changes due to dragging. default = YES
@property(nullable,nonatomic,strong)UIColor *minimumTrackTintColor NS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;
@property(nullable,nonatomic,strong)UIColor *maximumTrackTintColor NS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;
@property(nullable,nonatomic,strong)UIColor *thumbTintColor NS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;
- (void)setThumbImage:(nullableUIImage *)image forState:(UIControlState)state;
- (void)setMinimumTrackImage:(nullableUIImage *)image forState:(UIControlState)state;
- (void)setMaximumTrackImage:(nullableUIImage *)image forState:(UIControlState)state;
- (nullableUIImage *)thumbImageForState:(UIControlState)state;
- (nullableUIImage *)minimumTrackImageForState:(UIControlState)state;
- (nullableUIImage *)maximumTrackImageForState:(UIControlState)state;
@property(nullable,nonatomic,readonly)UIImage *currentThumbImage;
@property(nullable,nonatomic,readonly)UIImage *currentMinimumTrackImage;
@property(nullable,nonatomic,readonly)UIImage *currentMaximumTrackImage;
- (CGRect)minimumValueImageRectForBounds:(CGRect)bounds;
- (CGRect)maximumValueImageRectForBounds:(CGRect)bounds;
- (CGRect)trackRectForBounds:(CGRect)bounds;
- (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value;
UISwitch 滑動開關
switchView = [[UISwitchalloc]initWithFrame:CGRectMake(100,300, 60,40)];
[switchViewaddTarget:selfaction:@selector(switchViewMethod:)forControlEvents:UIControlEventValueChanged];
switchView.on =YES; //開關狀態
switchView.onTintColor = [UIColorgreenColor]; //開啓的顏色
switchView.tintColor = [UIColorredColor];//關閉的顏色
switchView.thumbTintColor = [UIColorblackColor]; //滑動輪 的顏色
[self.viewaddSubview:switchView];
-(void)switchViewMethod:(UISwitch *)sender
{
if (sender.on) {
NSLog(@"開");
}else{
NSLog(@"關");
}
}
@property(nullable,nonatomic, strong)UIColor *onTintColor
@property(null_resettable,nonatomic, strong)UIColor *tintColor
@property(nullable,nonatomic, strong)UIColor *thumbTintColor
@property(nullable,nonatomic, strong)UIImage *onImage
@property(nullable,nonatomic, strong)UIImage *offImage
@property(nonatomic,getter=isOn)BOOL on;
- (instancetype)initWithFrame:(CGRect)frame
- (void)setOn:(BOOL)on animated:(BOOL)animated;// does not send action