您的位置:首页 > 产品设计 > UI/UE

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

2016-07-01 12:21 387 查看
转自:http://blog.csdn.net/reylen/article/details/22038607

[objc] view
plain copy

 print?





@interface UIView (RectCorner)  

  

@end  

  

@implementation UIView (RectCorner)  

- (void)setCornerOnTop {  

    UIBezierPath *maskPath;  

    maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds  

                                     byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)  

                                           cornerRadii:CGSizeMake(10.0f, 10.0f)];  

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];  

    maskLayer.frame = self.bounds;  

    maskLayer.path = maskPath.CGPath;  

    self.layer.mask = maskLayer;  

    [maskLayer release];  

}  

- (void)setCornerOnBottom {  

    UIBezierPath *maskPath;  

    maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds  

                                     byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight)  

                                           cornerRadii:CGSizeMake(10.0f, 10.0f)];  

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];  

    maskLayer.frame = self.bounds;  

    maskLayer.path = maskPath.CGPath;  

    self.layer.mask = maskLayer;  

    [maskLayer release];  

}  

- (void)setAllCorner {  

    UIBezierPath *maskPath;  

    maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds  

                                          cornerRadius:10.0];  

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];  

    maskLayer.frame = self.bounds;  

    maskLayer.path = maskPath.CGPath;  

    self.layer.mask = maskLayer;  

    [maskLayer release];  

}  

- (void)setNoneCorner{  

    self.layer.mask = nil;  

}  

  

@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) {}];

 该方法效果是插入一面视图移除一面视图,期间可以使用一些转场动画效果。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: