动画UISlider

时间:2013-11-26 16:17:11

标签: ios uislider

我正在为我的应用中的UIView,UIText,UILabel和UIImage元素设置动画,以便在按钮点击时转换到完美的位置。但是我使用的代码在UISlider上不起作用,我无法弄明白。谁能帮我吗。我的代码是:

[UIView animateWithDuration:0.8f delay:0.0f options:UIViewAnimationOptionTransitionNone animations: ^{
    if (!viewExpanded) {   //x y width height
        viewExpanded = YES; //going down
        _blueMove.frame = CGRectMake(0, 0, 500, 150); //slide down panel
        _titleLabel.frame = CGRectMake(30, 30, 247, 44); // player title
        _timeElapsed.frame = CGRectMake(40, 95, 34, 21); //time counter
        _duration.frame = CGRectMake(230, 95, 35, 21); //duration
        _playerBg.frame = CGRectMake(0, 84, 320, 45); //player bg colour box

    }else{  //going up
        viewExpanded = NO;
        _blueMove.frame = CGRectMake(0, 0, 500, 0);//slide down panel
        _titleLabel.frame = CGRectMake(30, -40, 274, 44);// player title
        _timeElapsed.frame = CGRectMake(40, -20, 34, 21); //time counter
        _duration.frame = CGRectMake(230, -20, 35, 21); //duration
        //_currentTimeSlider = CGRectMake(40, 0, 175, 34); //time slider
        _playerBg.frame = CGRectMake(0, -45, 320, 45); //player bg colour box


    }

你可以看到我已经在else语句中注释了我正在使用的示例来动画我的UISlider,但是这会引发错误。

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您发布的代码已将滑块注释掉

  //_currentTimeSlider = CGRectMake(40, 0, 175, 34); //time slider

它也缺少.frame