IOS UIView--动画、圆角的拓展


转自:http://blog.csdn.net/reylen/article/details/22038607

[objc]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. @interface UIView (RectCorner)  
  2.   
  3. @end  
  4.   
  5. @implementation UIView (RectCorner)  
  6. - (void)setCornerOnTop {  
  7.     UIBezierPath *maskPath;  
  8.     maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds  
  9.                                      byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)  
  10.                                            cornerRadii:CGSizeMake(10.0f10.0f)];  
  11.     CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];  
  12.     maskLayer.frame = self.bounds;  
  13.     maskLayer.path = maskPath.CGPath;  
  14.     self.layer.mask = maskLayer;  
  15.     [maskLayer release];  
  16. }  
  17. - (void)setCornerOnBottom {  
  18.     UIBezierPath *maskPath;  
  19.     maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds  
  20.                                      byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight)  
  21.                                            cornerRadii:CGSizeMake(10.0f10.0f)];  
  22.     CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];  
  23.     maskLayer.frame = self.bounds;  
  24.     maskLayer.path = maskPath.CGPath;  
  25.     self.layer.mask = maskLayer;  
  26.     [maskLayer release];  
  27. }  
  28. - (void)setAllCorner {  
  29.     UIBezierPath *maskPath;  
  30.     maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds  
  31.                                           cornerRadius:10.0];  
  32.     CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];  
  33.     maskLayer.frame = self.bounds;  
  34.     maskLayer.path = maskPath.CGPath;  
  35.     self.layer.mask = maskLayer;  
  36.     [maskLayer release];  
  37. }  
  38. - (void)setNoneCorner{  
  39.     self.layer.mask = nil;  
  40. }  
  41.   
  42. @end  

IOS动画中的枚举UIViewAnimationOptions

转自:http://www.daxueit.com/article/5609.html
首先这个枚举属于UIViewAnimation。我们经常使用的函数是[UIView animateWithDuration: animations:^{} completion:^(BOOL finished) {}];和[UIView animateWithDuration: animations:^{}];如果动画稍微复杂点,例如需要组合等等就可能用到这个函数:[UIView animateWithDuration: delay: options: animations: completion:^(BOOL finished) {}];刚开始接触的朋友看到一堆枚举可能就觉得烦,尤其是苹果那混乱的动画框架东一坨,西一坨。又是Quartz2D,又是核心动画跟臭袜子一样……没关系,捡回来接着穿。

  以上方法中的options一项需要传入一个枚举,这个枚举大概控制的是这几个要素:当前动画嵌套中的动画执行随时间的快慢种类(先快后慢等..)。动画要一直重复吗。如果我使用转场动画那么我用哪种转场效果。还有子动画嵌套在父动画中时我们如何对待父动画中的相同选项等等..

 正文:

UIViewAnimationOptionLayoutSubviews //提交动画的时候布局子控件,表示子控件将和父控件一同动画。

UIViewAnimationOptionAllowUserInteraction //动画时允许用户交流,比如触摸

UIViewAnimationOptionBeginFromCurrentState //从当前状态开始动画

UIViewAnimationOptionRepeat //动画无限重复

UIViewAnimationOptionAutoreverse //执行动画回路,前提是设置动画无限重复

UIViewAnimationOptionOverrideInheritedDuration //忽略外层动画嵌套的执行时间

UIViewAnimationOptionOverrideInheritedCurve //忽略外层动画嵌套的时间变化曲线

UIViewAnimationOptionAllowAnimatedContent //通过改变属性和重绘实现动画效果,如果key没有提交动画将使用快照

UIViewAnimationOptionShowHideTransitionViews //用显隐的方式替代添加移除图层的动画效果

UIViewAnimationOptionOverrideInheritedOptions //忽略嵌套继承的选项

//时间函数曲线相关

UIViewAnimationOptionCurveEaseInOut //时间曲线函数,由慢到快

UIViewAnimationOptionCurveEaseIn //时间曲线函数,由慢到特别快

UIViewAnimationOptionCurveEaseOut //时间曲线函数,由快到慢

UIViewAnimationOptionCurveLinear //时间曲线函数,匀速

//转场动画相关的

UIViewAnimationOptionTransitionNone //无转场动画

UIViewAnimationOptionTransitionFlipFromLeft //转场从左翻转

UIViewAnimationOptionTransitionFlipFromRight //转场从右翻转

UIViewAnimationOptionTransitionCurlUp //上卷转场

UIViewAnimationOptionTransitionCurlDown //下卷转场

UIViewAnimationOptionTransitionCrossDissolve //转场交叉消失

UIViewAnimationOptionTransitionFlipFromTop //转场从上翻转

UIViewAnimationOptionTransitionFlipFromBottom //转场从下翻转

 以上是浅略的理解,欢迎朋友有更好的指正,以免误人子弟。

 补充:关于最后一组转场动画它一般是用在这个方法中的:

    [UIView transitionFromView: toView: duration: options: completion:^(BOOL finished) {}];

 该方法效果是插入一面视图移除一面视图,期间可以使用一些转场动画效果。




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值