阻止动画:设置UIViewAnimationOptionCurveLinear

n.e*_*ind 1 iphone animation cocoa-touch objective-c uiview

对不起,这是非常基本的,但是我无法将AnimationOption从默认设置(EaseIn)设置为CurveLinear.这是我根据我在其他线程中读到的内容尝试的:

    -(void)animationShadow;
{
    [UIView animateWithDuration:4
                        options:UIViewAnimationOptionCurveLinear
                     animations:^{
...
Run Code Online (Sandbox Code Playgroud)

如果我拿出选项位,一切正常.如果没有,它会崩溃.我确定我没有拨打正确的命令.

这是整个块动画:

   -(void)animationShadow;
{
    [UIView animateWithDuration:4
                        options:UIViewAnimationOptionCurveLinear
                     animations:^{

        //UIViewAnimationOptionCurveLinear

        // animation 1
        [pageShadowView setTransform:CGAffineTransformMakeScale (3, 1)];
        [pageShadowView setFrame:CGRectMake(0-350, 0, CGRectGetWidth(pageShadowView.frame), CGRectGetHeight(pageShadowView.frame))];

        [UIView beginAnimations:@"pageCurlRightToLeftFinished" context:nil]; // Begin animation
        //[UIView setAnimationCurve:UIViewAnimationCurveLinear];
        [pageShadowView setFrame:CGRectMake(0-280, 0, CGRectGetWidth(pageShadowView.frame), CGRectGetHeight(pageShadowView.frame))];
        [UIView commitAnimations];



    } completion:^(BOOL finished){ ...
Run Code Online (Sandbox Code Playgroud)

编辑:

好的,我现在更新了这个,但如果我做第二个动画,我仍然会崩溃.我收到警告:UIView可能无法响应+ animateWithDuration ......:

- (无效)animationShadow; {

[pageShadowView setTransform:CGAffineTransformMakeScale (3, 1)];
[pageShadowView setFrame:CGRectMake(0-350, 0, CGRectGetWidth(pageShadowView.frame), CGRectGetHeight(pageShadowView.frame))];


[UIView animateWithDuration:kPageCurlSpeed/4
                      delay:0
                    options:UIViewAnimationOptionCurveLinear
                 animations:^{
            [pageShadowView setFrame:CGRectMake(0-280, 0, CGRectGetWidth(pageShadowView.frame), CGRectGetHeight(pageShadowView.frame))];
                            }
                 completion:^(BOOL finished){


                     [UIView animateWithDuration:kPageCurlSpeed
                                           delay:0
                                         options:UIViewAnimationOptionCurveLinear
                                      animations:^{
                                          // animation 2

                                          [pageShadowView setTransform:CGAffineTransformMakeScale (0.1, 1)];
                                          [pageShadowView setFrame:CGRectMake((340-pageShadowView.frame.size.width), 0, CGRectGetWidth(pageShadowView.frame), CGRectGetHeight(pageShadowView.frame))];

                                      }
                      ]; // this is where I get the warning!!



                     }];

}
Run Code Online (Sandbox Code Playgroud)

ken*_*ytm 8

编辑:动画初始化代码应放在动画块之外.该块指定视图在动画结束时应达到的最终状态.

[pageShadowView setTransform:CGAffineTransformMakeScale(3, 1)];
[pageShadowView setFrame:CGRectMake(-350, ...)];

[UIView animateWithDuration:4 delay:0
                    options:UIViewAnimationOptionCurveLinear 
                 animations:^{
                              [pageShadowView setFrame:CGRectMake(-280, ...)];
                            }
                 completion:NULL];
Run Code Online (Sandbox Code Playgroud)

如果要按顺序运行2个动画,则应将第2个动画放入completion块中.

[UIView animateWithDuration:4 delay:0
                    options:UIViewAnimationOptionCurveLinear
                 animations:^{ /* animation 1 */ }
                 completion:^(BOOL finished) {
                               /* animation 2 */
                            }];
Run Code Online (Sandbox Code Playgroud)


Pet*_*son 5

如果您发现所选曲线被忽略,请检查您是否使用了正确的开关组.

有一个名为UIViewAnimationCurveLinear(用于旧方法)和UIViewAnimationOptionCurveLinear(用于块方法),它很容易混合起来.有相应的等效对,以方便,缓和等.

这引起了我的注意,所以我认为我确保其他人可以轻松看到这些信息.