Xcode學習之UIView動畫例子實踐
Xcode學習之UIView動畫例子實踐是本文要介紹的內容,主要是學習UIView動畫例子實踐,來學習xcode的相關內容,進一步的去學習和了解xcode,先來看內容詳解。
淡入淡出效果的例子,其中對象關系圖:
- SampleAppDelegate
 - HelloController init
 - ToggleView init
 - UIImageView init
 - self addSubview
 - UIImageView release
 - ToggleView release
 
其它對象釋放
關于淡入淡出的事件觸發(fā)放在ToggleView的touchesBegan事件,實現(xiàn)的是對ToggleView本身的動畫,從而達到對子視圖UIImageView的淡出淡入的效果的控制,而UIImageView視圖作為子視圖不允許發(fā)生觸摸交換(imgView.userInteractionEnabled = NO;),僅控制自身的顯示情況
現(xiàn)在學習下UIView的新方法,下面是淡入淡出效果實現(xiàn);
- // perform the fade out or fade in
 - CGContextRef context = UIGraphicsGetCurrentContext();
 - [UIView beginAnimations:nil context:context];
 - [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
 - [UIView setAnimationDuration:1.0];
 - [[self viewWithTag:IMAGE_VIEW_TAG] setAlpha:(float)isVisible];//注意,這個對當前子視圖設置顯示屬性
 - [UIView commitAnimations];
 
UIView類
類方法:(動畫部分)
- beginAnimations:context:
 - + (void)beginAnimations:(NSString *)animationID context:(void *)context
 - Marks the beginning of a begin/commit animation block.
 - setAnimationCurve:
 - + (void)setAnimationCurve:(UIViewAnimationCurve)curve
 - Sets the curve to use when animating property changes within an animation block.
 - setAnimationDuration:
 - + (void)setAnimationDuration:(NSTimeInterval)duration
 - Sets the duration (measured in seconds) of the animations in an animation block.
 - commitAnimations
 - + (void)commitAnimations
 - Marks the end of a begin/commit animation block and schedules the animations for execution.
 
Constants/常量
- UIViewAnimationCurveEaseInOut
 - An option for specifying an ease-in ease-out timing curve for the animation. An ease-in ease-out curve causes the animation to begin slowly,
 - accelerate through the middle of its duration, and then slow again before completing. This is the default curve for most animations.
 - UIViewAnimationCurveEaseIn
 - An option for specifying an ease-in timing curve for the animation. An ease-in curve causes the animation to begin slowly,
 - and then speed up as it progresses.
 - UIViewAnimationCurveEaseOut
 - An option for specifying an ease-out timing curve for the animation. An ease-out curve causes the animation to begin quickly,
 - and then slow down as it finishes.
 - UIViewAnimationCurveLinear
 - An option for specifying a linear timing curve for the animation. A linear animation curve causes an animation to occur evenly over its duration.
 
小結:Xcode學習之UIView動畫例子實踐的內容介紹完了,希望本文對你有所幫助!















 
 
 
 
 
 
 