iOS UIView的简单渐变效果

这里主要用到了ios4.0以后 UIView的类方法 animateWithDuration:

函数原型包括以下类方法

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

参数介绍

duration:动画的持续时间

annimations:动画的实体

completion:annimations执行完后立即执行的代码

options:枚举值,动画执行期间的一些设置

 

下面是可以设置动画效果的属性:

  • frame
  • bounds
  • center
  • transform
  • alpha
  • backgroundColor
  • contentStretch

动画效果的代码块可以有多个属性

[UIView animateWithDuration:0.5 animations:^{
            view.alpha = 0;
            view.frame = CGRectMake(0, 0, 100, 100);
        }];

 

 
posted @ 2016-01-26 17:22  小红烧  阅读(1161)  评论(0编辑  收藏  举报