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
转自:http://www.daxueit.com/article/5609.html
[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) {}]; 该方法效果是插入一面视图移除一面视图,期间可以使用一些转场动画效果。
相关文章推荐
- fuel8:fm安装所需要的网卡外接口
- Securing MQTT communication between Ardruino and Mosquitto
- IOS UITableView代码添加数据源和指定委托
- UIScrollViewDelegate详解
- intellij idea自动生成serialVersionUID
- hive & hue 中文乱码的问题
- JAVA线程池ThreadPoolExecutor与阻塞队列BlockingQueue
- TIPTOP GP5.1 实现链接网页方法 ui.Interface.frontCall
- 谷歌原生自动化框架UiAutomator1.0
- iOS VoiceOver Programming Guide
- JavaGUI版本销售管理系统
- HDU——1242Rescue(BFS+优先队列求点图最短路)
- UIBezierPath精讲
- 自定义View重绘使requestLayout, invalidate和postInvalidate的异同
- UGUI Text组件实际文本宽高的获取
- Android消息处理机制(Handler、Looper、MessageQueue与Message)
- tableView设置UITableViewStyleGrouped顶部有空余高度
- Starting MySQL...The server quit without updating PID file
- UIToolBar barItem的位置
- 启动安卓模拟器报错 emulator: ERROR: x86_64 emulation currently requires hardware acceleration! CPU acceleration status:HAXM must be updated(version 1.1.1<6.0.1) 解决办法