Xcode學(xué)習(xí)之UIView動(dòng)畫(huà)例子實(shí)踐
Xcode學(xué)習(xí)之UIView動(dòng)畫(huà)例子實(shí)踐是本文要介紹的內(nèi)容,主要是學(xué)習(xí)UIView動(dòng)畫(huà)例子實(shí)踐,來(lái)學(xué)習(xí)xcode的相關(guān)內(nèi)容,進(jìn)一步的去學(xué)習(xí)和了解xcode,先來(lái)看內(nèi)容詳解。
淡入淡出效果的例子,其中對(duì)象關(guān)系圖:
- SampleAppDelegate
- HelloController init
- ToggleView init
- UIImageView init
- self addSubview
- UIImageView release
- ToggleView release
其它對(duì)象釋放
關(guān)于淡入淡出的事件觸發(fā)放在ToggleView的touchesBegan事件,實(shí)現(xiàn)的是對(duì)ToggleView本身的動(dòng)畫(huà),從而達(dá)到對(duì)子視圖UIImageView的淡出淡入的效果的控制,而UIImageView視圖作為子視圖不允許發(fā)生觸摸交換(imgView.userInteractionEnabled = NO;),僅控制自身的顯示情況
現(xiàn)在學(xué)習(xí)下UIView的新方法,下面是淡入淡出效果實(shí)現(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];//注意,這個(gè)對(duì)當(dāng)前子視圖設(shè)置顯示屬性
- [UIView commitAnimations];
UIView類(lèi)
類(lèi)方法:(動(dòng)畫(huà)部分)
- 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.
小結(jié):Xcode學(xué)習(xí)之UIView動(dòng)畫(huà)例子實(shí)踐的內(nèi)容介紹完了,希望本文對(duì)你有所幫助!