0

Im trying to control a UIView's animation duration with a UISlider. The animation works fine and runs as if the duration is set to 1.0, but it doesn't respond to the slider. I'm kinda new so any help is greatly appreciated.

@interface ViewController (){
    float number;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [_slider setMinimumValue:0.5];
    [_slider setMaximumValue:1.0];
    [_slider setValue:0.5];

    number = _label.text.floatValue;

    _image.frame = 1

    [UIView animateWithDuration:number delay:0.1f options:UIViewAnimationOptionCurveLinear | UIViewKeyframeAnimationOptionAutoreverse | UIViewKeyframeAnimationOptionRepeat animations:^{
        _image.frame2;
    }
    completion:^(BOOL finished) {
        _image.frame1;
    }];
}

- (IBAction)sliderAction:(id)sender {
    _label.text = [NSString stringWithFormat:@"%f", _slider.value];
}

@end
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Jeff
  • 840
  • 10
  • 29
  • Can you explain what you mean by "it doesn't respond to the slider"? The code you provided doesn't animate the slider, it will animate _image. – InkGolem Jun 30 '15 at 20:51
  • 1
    See http://stackoverflow.com/questions/13991465/stop-an-auto-reverse-infinite-repeat-uiview-animation-with-a-bool-completion?s=1|0.6044 – rmaddy Jun 30 '15 at 20:52
  • @inkGolem, Yes my intention is to animate a UIImageView speed / duration with a UISlider. As rmaddy pointed out, looks like we must stop the animation before changing the duration. Thank you rmaddy :) – Jeff Jul 01 '15 at 18:33

0 Answers0