Xcode学习之UIView动画例子实践
Xcode学习之UIView动画例子实践是本文要介绍的内容,主要是学习UIView动画例子实践,来学习xcode的相关内容,进一步的去学习和了解xcode,先来看内容详解。
淡入淡出效果的例子,其中对象关系图:
SampleAppDelegate HelloController init ToggleView init UIImageView init self addSubview UIImageView release ToggleView release
其它对象释放
关于淡入淡出的事件触发放在ToggleView的touchesBegan事件,实现的是对ToggleView本身的动画,从而达到对子视图UIImageView的淡出淡入的效果的控制,而UIImageView视图作为子视图不允许发生触摸交换(imgView.userInteractionEnabled = NO;),仅控制自身的显示情况
现在学习下UIView的新方法,下面是淡入淡出效果实现;
// 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/常量