溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

IOS學(xué)習(xí)筆記(六)之UISlider的概念和使用方法

發(fā)布時(shí)間:2020-06-21 05:03:27 來源:網(wǎng)絡(luò) 閱讀:910 作者:jiangqq900826 欄目:移動(dòng)開發(fā)

IOS學(xué)習(xí)筆記(六)之IOS開發(fā)-UISlider的概念和使用方法

     Author:hmjiangqq

     Email:jiangqqlmj@163.com

UISlider視圖:

作用:控制系統(tǒng)聲音,或者表示播放進(jìn)度。

類的繼承圖如下:

IOS學(xué)習(xí)筆記(六)之UISlider的概念和使用方法

 A UISlider object is a visual control used to select a single value from a continuous range of values. Sliders are always displayed as horizontal bars.   An indicator, or thumb, notes the current value of the slider and can be moved by the user to change the setting.

常用的屬性和方法如下:

IOS學(xué)習(xí)筆記(六)之UISlider的概念和使用方法

我們?cè)谑褂没瑝K控件的時(shí)候,可以進(jìn)行設(shè)置滑塊的最大值,最小值,初始值。滑塊的值的范圍為

0.0f-1.0f之間的浮點(diǎn)數(shù)。值的設(shè)置方法如下:

-(void)setValue:(float)value animated:(BOOL)animated

部分屬性方法解釋如下:

@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(nonatomic,retain) UIImage *minimumValueImage;          // default is nil. p_w_picpath that appears to left of control (e.g. speaker off)  @property(nonatomic,retain) UIImage *maximumValueImage;     - (void)setValue:(float)value animated:(BOOL)animated; // move slider at fixed velocity (i.e. duration depends on distance). 

示例代碼如下:  


    UISlider *slider=[[UISlider alloc]initWithFrame:CGRectMake(60, 100, 200, 30)];     slider.tag=101;     //設(shè)置最大值     slider.maximumValue=1;     //設(shè)置最小值     slider.minimumValue=0;     //設(shè)置默認(rèn)值     slider.value=0.8f;     //設(shè)置值(帶有動(dòng)畫)     //[slider setValue:.5 animated:YES];     //添加事件     [slider addTarget:self action:@selector(valueChange:) forControlEvents:(UIControlEventValueChanged)];     [self.window addSubview:slider];     [slider release];          //[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(test:) userInfo:slider repeats:YES];          [self.window makeKeyAndVisible];     return YES; } -(void)valueChange:(UISlider *)slider{     NSLog(@"slider value : %.2f",[slider value]); }  -(void)test :(NSTimer *)timer{     UISlider *slider=timer.userInfo;     [slider setValue:0.5f animated:YES]; } 






向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI