Xcode学习之UIView动画例子实践

移动开发 iOS
本文介绍的是Xcode学习之UIView动画例子实践,详细的介绍了UIView动画例子实践的内容,先来看内容详解。

Xcode学习之UIView动画例子实践是本文要介绍的内容,主要是学习UIView动画例子实践,来学习xcode的相关内容,进一步的去学习和了解xcode,先来看内容详解。

淡入淡出效果的例子,其中对象关系图:

  1. SampleAppDelegate  
  2.     HelloController init  
  3.         ToggleView init  
  4.             UIImageView init  
  5.             self addSubview  
  6.             UIImageView release  
  7.         ToggleView release 

其它对象释放

关于淡入淡出的事件触发放在ToggleView的touchesBegan事件,实现的是对ToggleView本身的动画,从而达到对子视图UIImageView的淡出淡入的效果的控制,而UIImageView视图作为子视图不允许发生触摸交换(imgView.userInteractionEnabled = NO;),仅控制自身的显示情况

现在学习下UIView的新方法,下面是淡入淡出效果实现;

  1.   // perform the fade out or fade in      
  2. CGContextRef context = UIGraphicsGetCurrentContext();      
  3. [UIView beginAnimations:nil context:context];      
  4. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];      
  5. [UIView setAnimationDuration:1.0];      
  6. [[self viewWithTag:IMAGE_VIEW_TAG] setAlpha:(float)isVisible];//注意,这个对当前子视图设置显示属性      
  7. [UIView commitAnimations]; 

UIView类

类方法:(动画部分)

  1. beginAnimations:context:  
  2.  
  3. + (void)beginAnimations:(NSString *)animationID context:(void *)context  
  4.  
  5. Marks the beginning of a begin/commit animation block.  
  6.  
  7. setAnimationCurve:  
  8.  
  9. + (void)setAnimationCurve:(UIViewAnimationCurve)curve  
  10.  
  11. Sets the curve to use when animating property changes within an animation block.  
  12.  
  13. setAnimationDuration:  
  14.  
  15. + (void)setAnimationDuration:(NSTimeInterval)duration  
  16.  
  17. Sets the duration (measured in seconds) of the animations in an animation block.  
  18.  
  19. commitAnimations  
  20.  
  21. + (void)commitAnimations  
  22.  
  23. Marks the end of a begin/commit animation block and schedules the animations for execution. 

Constants/常量

  1. UIViewAnimationCurveEaseInOut  
  2.  
  3. 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,
  4.  accelerate through the middle of its duration, and then slow again before completing. This is the default curve for most animations.  
  5.  
  6. UIViewAnimationCurveEaseIn  
  7.  
  8. An option for specifying an ease-in timing curve for the animation. An ease-in curve causes the animation to begin slowly, 
  9. and then speed up as it progresses.  
  10.  
  11. UIViewAnimationCurveEaseOut  
  12.  
  13. An option for specifying an ease-out timing curve for the animation. An ease-out curve causes the animation to begin quickly, 
  14. and then slow down as it finishes.  
  15.  
  16. UIViewAnimationCurveLinear  
  17.  
  18. 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动画例子实践的内容介绍完了,希望本文对你有所帮助!

责任编辑:zhaolei 来源: 博客园
相关推荐

2011-08-01 10:13:46

Xcode 视图 动画

2012-12-24 13:38:01

iOSUIView

2011-08-16 18:13:42

IPhone开发UIView动画

2011-07-20 14:31:56

XCode User Scrip 脚本

2011-08-01 15:57:58

2011-08-01 16:50:28

Xcode 动态 View

2011-08-15 13:50:06

IPhone开发UIView动画

2011-08-01 17:01:02

Xcode WindowBase View

2011-08-12 11:31:46

iPhoneUIView动画

2011-08-01 17:50:28

Xcode

2011-08-10 14:00:22

XcodeUIWebView视频

2011-08-11 16:31:08

XCode

2011-08-18 10:17:21

Xcode4Xcode

2011-07-25 15:42:38

Xcode Vim

2011-08-03 16:26:14

iPhone UIView 动画

2011-08-03 16:35:10

iPhone UIView 动画

2011-08-08 17:05:02

XCode UserScript 脚本

2013-07-25 15:19:23

iOS开发学习Xcode打包framiOS开发

2011-08-01 09:26:51

Xcode Xcode 4 Instrument

2011-08-19 15:16:41

XCodeUserScripts脚本
点赞
收藏

51CTO技术栈公众号