简体   繁体   English

UIView线性动画移动视图

[英]UIView Linear Animation Moving View

My intention is to move a UIView Object. 我的意图是移动UIView对象。

The Code I use for this is: 我为此使用的代码是:

[UIView animateWithDuration:(biggestViewWidth * 0.005) delay:1.0 options:UIViewAnimationOptionCurveLinear animations:^{


            //
            [view setFrame:CGRectMake(0, view.frame.origin.y, view.frame.size.width, view.frame.size.height)];

            // View verschieben
            [view setFrame:CGRectMake(-view.frame.size.width - 10, view.frame.origin.y, view.frame.size.width, view.frame.size.height)];

        } ...

But as is the example shown the view is linear moved to the new x position. 但是,如示例所示,视图是线性移动到新的x位置的。 Is it possible to say that the Animation should go with a step of 20 points for example more and more to the left? 可以说动画应该向左移动20点,例如越来越多吗? So for example: startX = 0; 例如:startX = 0; 1. = -20; 1. = -20; 2. = -40; 2. = -40; . . .

There are several ways to customize the animation curves. 有几种自定义动画曲线的方法。 The easiest is to pass in one of these to your existing function: https://developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/UIView/UIView.html#jumpTo_153 最简单的方法是将其中之一传递给您现有的函数: https : //developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/UIView/UIView.html#jumpTo_153

Otherwise, you can setup your own animation using keyframes as in this example: https://github.com/ShinobiControls/iOS7-day-by-day/blob/master/11-uiview-keyframe-animation/11-uiview-keyframe-animation.md 否则,您可以像以下示例一样使用关键帧设置自己的动画: https : //github.com/ShinobiControls/iOS7-day-by-day/blob/master/11-uiview-keyframe-animation/11-uiview-keyframe -animation.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM