Can i control slider value programaticaly?

穿精又带淫゛_ 提交于 2019-12-13 05:41:46

问题


I have used following code

for (UIView *view in [volumeView subviews]){
    if ([[[view class] description] isEqualToString:@"MPVolumeSlider"]) {
        volumeViewSlider = (UISlider *) view;
    }
}

//[volumeViewSlider setBackgroundColor:[UIColor colorWithRed:1.00 green:0.0 blue:0.0 alpha:1.0]];
UIImage *stetchLeftTrack = [[UIImage imageNamed:@"leftslide.png"]
                            stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
UIImage *stetchRightTrack = [[UIImage imageNamed:@"rightslide.png"]
                             stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
//    [customSlider setThumbImage: [UIImage imageNamed:@"slider_ball.png"] forState:UIControlStateNormal];
[volumeViewSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
[volumeViewSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
[volumeViewSlider setMinimumValueImage:[UIImage imageNamed:@"SpeakerSoft.tif"]];
[volumeViewSlider setMaximumValueImage:[UIImage imageNamed:@"SpeakerLoud.tif"]];


[NSTimer scheduledTimerWithTimeInterval:60.0 target:self selector:@selector(changeTheTimer) userInfo:nil repeats:NO];
}

-(void)changeTheTimer{
[volumeViewSlider setValue:0 animated:YES];
NSLog(@"Value is set to 0");

}

I want to stop all playbacks after one minute , but slider moves to zero and leaves of effect of master volume , please help


回答1:


You can certainly make use of the UISlider instance method

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

This will reduce the slider value with or without animation.

UPDATE

Check this link on Controlling Master Volume



来源:https://stackoverflow.com/questions/6210564/can-i-control-slider-value-programaticaly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!