亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

iOSProgrammingControllingAnimations動畫

2019-11-14 18:57:02
字體:
來源:轉載
供稿:網友

iOS PRogramming Controlling Animations 動畫

The Word "animation" is derived from a Latin word that means "the act of bringing to life." Animations are what bring your applications to life, and when used appropriately, they can guide your users through a course of actions, orient them, and overall create a delightful experience.

animation 源自拉丁詞意思是帶入聲明的動作。animations 是把你的應用帶到life,當你恰當的使用,他們能引導你的用戶通過一系列動作,orient 他們,全部創建一個delightful experience.

you will use a variety of animation techniques to animate various views in the HypnoNerd application.

在本章,你將使用各種各樣的animation techniques to animate 各種views在HypnoNerd應用。

1. Basic Animations 基礎的動畫

Animations are a great way to add an extra layer of polish to any application; games are not the only type of application to benefit from animations.

animations 是一種很好的方式添加到任何應用上的額外的層。games 不是從animations 獲利的唯一一種應用。

Animations can smoothly bring interface elements on screen or into focus, they can draw the user's attention to an actionable item, and they give clear indications of how your app is responding to the user's actions.

動畫能夠平滑的把界面元素帶到屏幕上或者引起注意,他們能吸引用戶的注意到他們動作的item,他們給了清晰的暗示來怎樣讓你的app響應用戶的actions.

The first type of animation you are going to use is the basic animation. A basic animation animates between a start value and an end value

你將使用的第一個動畫是basic animation.basic animation animates 在一個開始的值和一個end value之間動作。

The first animation you will add will animate the alpha value of the labels when they are added to the view.

你將添加的第一個動畫是animate the alpha value of the labels 當他們添加到view上時。

messageLabel.alpha=0;

? ? ? ? [UIView animateWithDuration:0.5 animations:^{

? ? ? ? ? ? messageLabel.alpha=1;

? ? ? ? }];

?

After you enter some text and tap the return key, the labels should fade into view. Animations provide a less jarring user experience than having the views just pop into existence.

Animations 提供了一個更少的用戶等待時間比直接讓view 出現體驗更好。

The method animateWithDuration:animations: returns immediately. That is, it starts the animation, but does not wait around for the animation to complete.

animateWithDuration:animations直接返回。也就是說它開始一個animation,但是并不會等到動畫完成。

The simplest block-based animation method on UIView is animateWithDuration:animations:. This method takes in the duration that the animation should run for and a block of changes to animate.?

最簡單的block—based animation 方法在UIView是animateWithDuration:animations.這個方法傳入一個動畫應該運行的時間和一個block? of changes to animate.

The animation will follow an ease-in/ease-out animation curve, which will cause the animation to begin slowly, accelerate through the middle, and finally slow down at the end.

動畫會跟隨ease-in/ease-out animation curve,這將導致animation 開始慢,中間加速,最后減速的效果。

1.1 Timing functions?

The acceleration of the animation is controlled by its timing function. The method animateWithDuration:animations: uses an ease-in/ease-out timing function.?

動畫的acceleration 是由它的timing function 控制的。這個animateWithDuration:animations使用了ease-in/ease-out timing function.

To use a driving analogy, this would mean the driver accelerates smoothly from rest to a constant speed, and then gradually slows down at the end, coming to rest.

用一個開車的比喻,這意味著從rest 到一個恒速平滑的加速,然后漸漸的減速,直到rest。

Other timing functions include linear (a constant speed from beginning to end), ease-in (accelerating to a constant speed, and then ending abruptly), and ease-out (beginning at full speed, and then slowing down at the end).

其他的timing funcitons 包括linear(從開始到結束都是勻速),ease-in(加速到一個常量,然后突然結束),ease-out(開始全速,最后減速)

In order to use one of these other timing functions, you will need to use the UIView animation method that allows options to be specified: animateWithDuration:delay:options:animations:completion:.

為了使用這些其他的timing functions,你需要使用哪些允許options 來指明的animateWithDuration:delay:options:animations:completion:.

的UIView animation 方法。

This method gives you the most control over the animation. In addition to the duration and animation block, you can also specify how long to delay before the animations should begin, some options (which we will look at shortly), and a completion block that will get called when the animation sequence completes.

這個方法給你了更多的控制在整個animation.除了duration 和animation block ,你可以指明在動畫開始之前需要delay 多久,和一些options和一個completion block 當animation sequence completes 時被調用。

?[UIView animateWithDuration:2 delay:5 options:UIViewAnimationOptionCurveEaseIn animations:^{

? ? ? ? ? ? messageLabel.alpha=1;

? ? ? ? } completion:NULL];

Now, as opposed to using the default ease-in/ease-out animation curve, the animation will just ease- in.

The options argument is a bitmask, so you can bitwise-or multiple values together. Here are some of the useful options that you can supply:

optinons 參數是bit mask,所以你可以bitwise或者multiple values together.這里是你能提供的一些有用的信息。

These control the acceleration of the animation. Possible values are

UIViewAnimationOptionCurveEaseInOut

UIViewAnimationOptionCurveEaseIn

UIViewAnimationOptionCurveEaSEOut

UIViewAnimationOptionCurveLinear

?

UIViewAnimationOptionAllowUserInteraction

By default, views cannot be interacted with when animating. Specifying this option will override the default. This can be useful for repeating animations, such as a pulsing view.

默認情況下,views 不能交流當animating時。指明這個選項將override 這個default.這在repeating animations ,例如pulsing view 時會很有用

UIViewAnimationOptionRepeat

This will repeat the animation indefinitely. This is often paired with the UIViewAnimationOptionAutoreverse option.

這個將無限期的這個動畫。它經常與UIViewAnimationOptionAutoreverse一起用。

UIViewAnimationOptionAutoreverse

This will run the animation forward and then backward, returning the view to its initial state.

這將運行animation 前進然后后退,返回view到她的 初始狀態。

2 ?Keyframe Animations

The animations you have added so far have been basic animations; they animate from one value to another value.

你目前添加的動畫都是basic animations.

If you want to animate a view's properties through more than two values, you use a keyframe animation. A keyframe animation can be made up of any number of individual keyframes (Figure 27.3). You can think of keyframe animations as multiple basic animations going back to back.

如果你想animate 一個view 的properties經過多于兩個值,你要用keyframe animation. 一個keyframe animation 能夠由任意數量的獨立的keyframes 組成。你可以認為keyframe animations 為multiple basic animations 來來回回。

Keyframe animations are set up similarly to basic animations, but each keyframe is added separately.

keyframe animations 與basic animations 的設置非常相近,但是每個keyframe被分別的添加。

?

To create a keyframe animation, use the animateKeyframesWithDuration:delay:options:animations:completion: class method on UIView, and add keyframes in the animation block using the addKeyframeWithRelativeStartTime:relativeDuration:animations: class method.

?

In BNRHypnosisViewController.m, update drawHypnoticMessage: to animate the center of the labels first to the middle of the screen and then to another random position on the screen.

?

更新drawHypotic Message? 來animate the? center of the labels 先在screen 的中間,然后到任意其他的屏幕的位置。

Keyframe animations are created using animateKeyframesWithDuration:delay:options:animations:completion:. The parameters are all the same as with the basic animation except that the options are of type UIViewKeyframeAnimationOptions instead of UIViewAnimationOptions. The duration passed into this method is the duration of the entire animation.

keyframe animations 使用animateKeyframesWithDuration:delay:options:animations:completion來創建。參數除了options 的類型是UIViewKeyframeAnimationOptions而不是UIViewAnimationOptions之外,都一樣。傳遞給這個方法的duration 是整個animation 的duration。

Individual keyframes are added using addKeyframeWithRelativeStartTime:relativeDuration:animations:.

單獨的keyframes 由addKeyframeWithRelativeStartTime:relativeDuration:animations添加。

The first argument is the relative start time, which will be a value between 0 and 1. The second argument is the relative duration, which is a percent of the total duration and will also be a value between 0 and 1.

第一個參數是相對開始時間,將會是0到1 之間的數。第二個參數是相對持續時間。是整個duration 百分比,值仍然是在0-1之間。

?[UIView animateKeyframesWithDuration:5.0 delay:0 options:0 animations:^{

? ? ? ? ? ? [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.6 animations:^{

? ? ? ? ? ? ? ? messageLabel.center=self.view.center;

? ? ? ? ? ? }];

? ? ? ? ? ? [UIView addKeyframeWithRelativeStartTime:0.6 relativeDuration:0.4 animations:^{

? ? ? ? ? ? ? ? int x=arc4random()%width;

? ? ? ? ? ? ? ? int y=arc4random()%height;

? ? ? ? ? ? ? ? messageLabel.center=CGPointMake(x, y);

?? ? ? ? ? ? ? ??

? ? ? ? ? ? }];

?? ? ? ? ? ??

? ? ? ? } completion:NULL];

?

3 Animation Completion?

It can often be useful to know when an animation completes.?

知道animation什么時候完成是有用的。

For instance, you might want to chain different kinds of animations together or update another object when the animation completes. To know when the animation finishes, pass a block for the completion argument.

例如,你可能想連接不同種類的動畫一起或者當animation 完成時,更新另一個對象。為了知道animation 什么時候完成,傳遞一個block 為compleiton 參數。

Build and run the application, and log messages will appear in the console as soon as the animations complete.

?

You might be wondering, "What if the animation repeats? Will the completion block be executed after each repeat?" No, the completion block will only be executed once, at the very end.

你可能會想:"如果animation 重復怎么辦?completion block 是否被反復執行?",不是,completion block 將僅僅執行一次,在最后。

4 Spring Animations?

iOS has a powerful physics engine built into the SDK, and one of the easiest ways to use it is with the new spring animations.

iOS 有一個強大的物理引擎構建在SDK中,使用它的最簡單的方式是用新的spring animations.

This type of animation has a timing function like that of an actual spring. You will use this to animate the text field dropping in from the top of the screen, as if it was attached to a spring.

這個類型的animation 有一個timing functions 像一個實際的spring。 你可以用這個animate 這個text field 從screen

頂端滑落,好像是依附在一個spring上。

In BNRHypnosisViewController.m, add a property for the text field to the class extension and update loadView to store the reference to the text field. Then start with the text field offscreen:

@property (nonatomic, weak) UITextField *textField;

?

self.textField = textField;

?

It will be best to begin the animation as soon as the view is on the screen, so the animation code will go into viewDidAppear:. Currently there is no property pointing to the text field, but you will need one in order to update its frame in viewDidAppear:.

?

Now, in BNRHypnosisViewController.m, override viewDidAppear: to drop in the text field using a spring animation.

?

- (void)viewDidAppear:(BOOL)animated {

[super viewDidAppear:animated];

[UIView animateWithDuration:2.0 delay:0.0

usingSpringWithDamping:0.25 initialSpringVelocity:0.0

options:0 animations:^{

CGRect frame = CGRectMake(40, 70, 240, 30);

self.textField.frame = frame; }

completion:NULL];

}

The individual components of this method are relatively straightforward:

這個方法獨立的組成是相當的直接:

duration :The total time the animation should last.

animation 將持續的整個時間。

delay

How long until the animation should begin.

什么時候開始animation.

spring dumping :

A number between 0 and 1. The closer to 0, the more the animation oscillates.

在0和1之間的數字。越靠近0,動畫越震蕩。

?spring velocity? ? The relative velocity of the view when the animation is to begin. You will almost always pass in 0 for this.

當動畫開始時,相關view 的速度。你總是傳遞0給這個。

options
UIViewAnimationOptions, just like with the other animations.?

UIViewAnimationOptions,就像其他的animations。

animaitons

A block of changes to animate on one or more views.

改變了animate on one 或多個views 的代碼塊

completion
A block to run when the animation is finished.

當animation 完成時運行的代碼塊。

?

?

?

?


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
亚洲xxxxx| 亚洲国产三级网| 日韩电影免费观看在线| 久久久久中文字幕2018| 久久免费精品视频| 亚洲另类图片色| 亚洲精品98久久久久久中文字幕| 精品女厕一区二区三区| 成人黄色影片在线| 日产精品久久久一区二区福利| 日本高清久久天堂| 国产精品视频一区二区三区四| 亚洲伦理中文字幕| 国产精品一区二区三| 日韩av日韩在线观看| 国产精品久久久999| 亚洲精品视频免费在线观看| 国产精品偷伦视频免费观看国产| 国产精品成人久久久久| 欧美怡红院视频一区二区三区| 91精品国产网站| 亚洲少妇激情视频| 欧美亚洲国产精品| 国产原创欧美精品| 亚洲香蕉成视频在线观看| 97国产一区二区精品久久呦| 在线日韩中文字幕| 色黄久久久久久| 亚洲最新av在线| 亚洲精品日韩丝袜精品| 国产丝袜一区视频在线观看| 国产精品∨欧美精品v日韩精品| 国产99久久精品一区二区 夜夜躁日日躁| 欧美精品videosex极品1| 日韩国产欧美精品在线| 亚洲精品国产综合区久久久久久久| 国产精品福利观看| 国产精品一香蕉国产线看观看| 精品在线小视频| 亚洲国产一区二区三区在线观看| 国色天香2019中文字幕在线观看| 久久精品电影一区二区| 久久久国产视频91| 亚洲欧洲免费视频| 国产成人极品视频| 久久亚洲电影天堂| 4k岛国日韩精品**专区| 国产精品久久久久久久久久小说| 国产精品av在线播放| 欧美疯狂性受xxxxx另类| 亚洲人成毛片在线播放| 久久久久久亚洲精品| 国产精品美女主播| 亚洲xxx自由成熟| 色偷偷91综合久久噜噜| 91青草视频久久| 国产成+人+综合+亚洲欧美丁香花| 亚洲天堂第二页| 国产精品黄视频| 2018国产精品视频| 国产一区二区三区在线| 91色中文字幕| 亚洲精品www久久久| 2018中文字幕一区二区三区| 91久久精品美女高潮| 亚洲欧美日韩天堂| 国产一区二区黑人欧美xxxx| 美女视频黄免费的亚洲男人天堂| 国产一区二区三区网站| 久久久午夜视频| 亚洲美女视频网| 色哟哟入口国产精品| 国产精品wwwwww| 在线观看国产精品91| 2020久久国产精品| 精品国产乱码久久久久久虫虫漫画| 一本大道香蕉久在线播放29| 国产精品成人免费视频| 色悠久久久久综合先锋影音下载| 精品动漫一区二区| 亚洲国产精品悠悠久久琪琪| 国产不卡av在线免费观看| 亚洲欧洲一区二区三区在线观看| 日韩av网站导航| 97激碰免费视频| 国模精品一区二区三区色天香| 日韩电影大片中文字幕| 日韩国产欧美精品一区二区三区| 日韩欧美精品免费在线| 欧美日韩免费在线| 成人网在线免费看| 韩日欧美一区二区| 韩剧1988免费观看全集| 亚洲mm色国产网站| 亚洲一品av免费观看| 亚洲qvod图片区电影| 欧美主播福利视频| 九九热精品视频国产| 久久偷看各类女兵18女厕嘘嘘| 欧美久久精品午夜青青大伊人| 欧美日韩免费区域视频在线观看| 国产精品久久久久久久久免费| 欧美性猛交99久久久久99按摩| 久久久久久久999精品视频| 91亚洲精品久久久| 久久69精品久久久久久久电影好| 国产97人人超碰caoprom| 日韩av免费在线播放| 成人激情在线播放| 亚洲欧美在线一区| 清纯唯美亚洲激情| 日韩在线视频中文字幕| 亚洲字幕在线观看| 精品久久久久久久久久久久久久| 日本高清不卡的在线| 一区二区三区视频免费| 欧美日韩免费观看中文| 免费成人高清视频| 欧美视频中文字幕在线| 97国产一区二区精品久久呦| 最近2019中文字幕一页二页| 国产精品久久久久久久久久免费| 96精品久久久久中文字幕| 高清视频欧美一级| 992tv成人免费视频| 91久久国产综合久久91精品网站| 日韩在线视频线视频免费网站| 中文日韩在线观看| 亚洲成人性视频| 最新69国产成人精品视频免费| 国产aⅴ夜夜欢一区二区三区| 亚洲va欧美va国产综合剧情| 成人h视频在线观看播放| 国产精品偷伦免费视频观看的| 国产亚洲精品91在线| 国产免费成人av| 欧美成人一二三| 国产主播精品在线| 国产精品亚洲片夜色在线| 色午夜这里只有精品| 欧美在线性爱视频| 国产精品海角社区在线观看| 韩曰欧美视频免费观看| 最新91在线视频| 8090理伦午夜在线电影| 在线观看视频亚洲| 一本色道久久综合狠狠躁篇的优点| 日韩av在线天堂网| 久久91亚洲精品中文字幕奶水| 国模精品系列视频| 国产极品jizzhd欧美| 精品一区二区三区电影| 欧美日韩午夜视频在线观看| 成人免费在线视频网址| 国产综合在线观看视频| 国产精品久久久久久久久久久久| 欧美老女人性视频| 欧洲精品在线视频| 麻豆成人在线看| 欧美一级成年大片在线观看| 欧美色播在线播放| 国内免费久久久久久久久久久| 亚洲片在线观看| 狠狠色狠色综合曰曰|