mNo edit summary |
mNo edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[UIViewAnimationState]] is the manager class of [[UIView]] animation blocks. The system maintains a private global stack that contains all ''pending'' animation states. When a state is popped, the corresponding animation begins. | |||
The animations will all go back to {{fwlink|QuartzCore}} (Core Animation). | |||
== Drag coefficient == | |||
{{function signature | |||
|signature=CGFloat UIAnimationDragCoefficient(); | |||
|firmware=2.0 – | |||
}} | |||
The ''drag coefficient'' is a multiplier applied on time measurements. A large drag coefficient can slow down animations. | |||
The drag coefficient is obtained with the <tt>UIAnimationDragCoefficient()</tt> function, which in turn is an ''integer'' of the key <tt>UIAnimationDragCoefficient</tt> in the preference file <tt>~/Library/Preferences/com.apple.UIKit.plist</tt>. | |||
Drag coefficient will not affect non-UIKit animations. | |||
== Animation transitions == | == Animation transitions == | ||
{{see|CATransition}} | |||
Besides the default 4, the iPhoneOS identifies tons of transition effects, all value numerical value starting from 101: | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 5: | Line 23: | ||
! Numeric | ! Numeric | ||
! String | ! String | ||
! Available on 3.x | |||
! Comments | ! Comments | ||
|- | |- | ||
| 0 (UIViewAnimationTransitionNone) | | 0 (UIViewAnimationTransitionNone) | ||
| - | | - | ||
| | | {{Yes}} || | ||
|- | |- | ||
| 1 (UIViewAnimationTransitionFlipFromLeft) | | 1 (UIViewAnimationTransitionFlipFromLeft) | ||
| oglFlip, fromLeft | | oglFlip, fromLeft | ||
| | | {{Yes}} || | ||
|- | |- | ||
| 2 (UIViewAnimationTransitionFlipFromRight) | | 2 (UIViewAnimationTransitionFlipFromRight) | ||
| oglFlip, fromRight | | oglFlip, fromRight | ||
| | | {{Yes}} || | ||
|- | |- | ||
| 3 (UIViewAnimationTransitionCurlUp) | | 3 (UIViewAnimationTransitionCurlUp) | ||
| pageCurl | | pageCurl | ||
| | | {{Yes}} || | ||
|- | |- | ||
| 4 (UIViewAnimationTransitionCurlDown) | | 4 (UIViewAnimationTransitionCurlDown) | ||
| pageUnCurl | | pageUnCurl | ||
| | | {{Yes}} || | ||
|- | |- | ||
| 101 | | 101 | ||
| pageCurl | | pageCurl | ||
| Equivalent to UIViewAnimationTransitionCurlUp | | {{Yes}} || Equivalent to UIViewAnimationTransitionCurlUp | ||
|- | |- | ||
| 102 | | 102 | ||
| pageUnCurl | | pageUnCurl | ||
| Equivalent to UIViewAnimationTransitionCurlDown | | {{Yes}} || Equivalent to UIViewAnimationTransitionCurlDown | ||
|- | |- | ||
| 103 | | 103 | ||
| suckEffect | | suckEffect | ||
| Sucked to around (160, 360) on the screen. | | {{Yes}} || Sucked to around (160, 360) on the screen. | ||
|- | |- | ||
| 104 | | 104 | ||
| spewEffect | | spewEffect | ||
| | | {{No}} || | ||
|- | |- | ||
| 105 | | 105 | ||
| cameraIris | | cameraIris | ||
| You should assume the view you're operating on has a black background. | | {{Yes}} || You should assume the view you're operating on has a black background. | ||
|- | |- | ||
| 106 | | 106 | ||
| cameraIrisHollowClose | | cameraIrisHollowClose | ||
| First half of cameraIris. | | {{Yes}} || First half of cameraIris. | ||
|- | |- | ||
| 107 | | 107 | ||
| cameraIrisHollowOpen | | cameraIrisHollowOpen | ||
| Second half of cameraIris. | | {{Yes}} || Second half of cameraIris. | ||
|- | |- | ||
| 108 | | 108 | ||
| genieEffect | | genieEffect | ||
| | | {{No}} || | ||
|- | |- | ||
| 109 | | 109 | ||
| unGenieEffect | | unGenieEffect | ||
| | | {{No}} || | ||
|- | |- | ||
| 110 | | 110 | ||
| rippleEffect | | rippleEffect | ||
| | | {{Yes}} || | ||
|- | |- | ||
| 111 | | 111 | ||
| twist | | twist | ||
| | | {{No}} || | ||
|- | |- | ||
| 112 | | 112 | ||
| tubey | | tubey | ||
| | | {{No}} || | ||
|- | |- | ||
| 113 | | 113 | ||
| swirl | | swirl | ||
| | | {{No}} || | ||
|- | |- | ||
| 114 | | 114 | ||
| charminUltra | | charminUltra | ||
| | | {{No}} || | ||
|- | |- | ||
| 115 | | 115 | ||
| zoomyIn | | zoomyIn | ||
| | | {{No}} || | ||
|- | |- | ||
| 116 | | 116 | ||
| zoomyOut | | zoomyOut | ||
| | | {{No}} || | ||
|- | |- | ||
| 117 | | 117 | ||
| oglApplicationSuspend | | oglApplicationSuspend | ||
| | | {{No}} || | ||
|} | |} | ||
Line 105: | Line 124: | ||
[UIView commitAnimations]; | [UIView commitAnimations]; | ||
</source> | </source> | ||
== Curl-up animation == | |||
Starting from 3.2, you can mimic the Maps curl-up animation using animation blocks. The syntax is: | |||
<source lang="objc"> | |||
[UIView beginAnimations:@"curlUp" context:NULL]; | |||
[UIView _setAnimationFilter:200 forView:view_to_curl_up]; | |||
[UIView _setAnimationFilterValue:height_to_curl_for]; | |||
[UIView commitAnimations]; | |||
</source> | |||
This is converted into a pageCurl filter, with the parameters: | |||
* inputRadius = 20 | |||
* inputAngle = 4.5379 (= 260°) | |||
* endTime = (200 + 0.174 width + 0.985 <tt>height_to_curl_for</tt>) / (200 + 0.174 width + 0.985 height), and clipped within [0.65, 0.9] | |||
== References == | == References == | ||
* All animation names: http://www.waterworld.com.hk/en/node/74 | * All animation names: http://www.waterworld.com.hk/en/node/74 | ||
{{IPFHeader|UIKit}} | {{IPFHeader|UIKit}} |
Latest revision as of 11:47, 6 February 2010
UIViewAnimationState is the manager class of UIView animation blocks. The system maintains a private global stack that contains all pending animation states. When a state is popped, the corresponding animation begins.
The animations will all go back to QuartzCore (Core Animation).
Drag coefficient
Signature | CGFloat UIAnimationDragCoefficient(); |
---|---|
Available in | 2.0 – |
The drag coefficient is a multiplier applied on time measurements. A large drag coefficient can slow down animations.
The drag coefficient is obtained with the UIAnimationDragCoefficient() function, which in turn is an integer of the key UIAnimationDragCoefficient in the preference file ~/Library/Preferences/com.apple.UIKit.plist.
Drag coefficient will not affect non-UIKit animations.
Animation transitions
Besides the default 4, the iPhoneOS identifies tons of transition effects, all value numerical value starting from 101:
Numeric | String | Available on 3.x | Comments |
---|---|---|---|
0 (UIViewAnimationTransitionNone) | - | Yes | |
1 (UIViewAnimationTransitionFlipFromLeft) | oglFlip, fromLeft | Yes | |
2 (UIViewAnimationTransitionFlipFromRight) | oglFlip, fromRight | Yes | |
3 (UIViewAnimationTransitionCurlUp) | pageCurl | Yes | |
4 (UIViewAnimationTransitionCurlDown) | pageUnCurl | Yes | |
101 | pageCurl | Yes | Equivalent to UIViewAnimationTransitionCurlUp |
102 | pageUnCurl | Yes | Equivalent to UIViewAnimationTransitionCurlDown |
103 | suckEffect | Yes | Sucked to around (160, 360) on the screen. |
104 | spewEffect | No | |
105 | cameraIris | Yes | You should assume the view you're operating on has a black background. |
106 | cameraIrisHollowClose | Yes | First half of cameraIris. |
107 | cameraIrisHollowOpen | Yes | Second half of cameraIris. |
108 | genieEffect | No | |
109 | unGenieEffect | No | |
110 | rippleEffect | Yes | |
111 | twist | No | |
112 | tubey | No | |
113 | swirl | No | |
114 | charminUltra | No | |
115 | zoomyIn | No | |
116 | zoomyOut | No | |
117 | oglApplicationSuspend | No |
Using suckEffect
The most SDK-compatible way of using suckEffect is to use animation blocks. But the suction point by default is close to nowhere. Therefore you still need to use the undocumented method +[UIView setAnimationPosition:]:
[UIView beginAnimations:@"suck" context:NULL];
[UIView setAnimationTransition:103 forView:myViewContainer cache:YES];
[UIView setAnimationPosition:CGPointMake(12, 345)];
[myView removeFromSuperview];
[UIView commitAnimations];
Curl-up animation
Starting from 3.2, you can mimic the Maps curl-up animation using animation blocks. The syntax is:
[UIView beginAnimations:@"curlUp" context:NULL];
[UIView _setAnimationFilter:200 forView:view_to_curl_up];
[UIView _setAnimationFilterValue:height_to_curl_for];
[UIView commitAnimations];
This is converted into a pageCurl filter, with the parameters:
- inputRadius = 20
- inputAngle = 4.5379 (= 260°)
- endTime = (200 + 0.174 width + 0.985 height_to_curl_for) / (200 + 0.174 width + 0.985 height), and clipped within [0.65, 0.9]
References
- All animation names: http://www.waterworld.com.hk/en/node/74
- Header: http://github.com/kennytm/iphone-private-frameworks/blob/master/UIKit/UIViewAnimationState.h