设置UIView几个角为圆角
2015-07-21 11:57
429 查看
UIButton *btn = [[UIButton
alloc] initWithFrame:CGRectMake(PhaseHalf(CGRectGetWidth(self.view.bounds),kWidth),
PhaseHalf(CGRectGetHeight(self.view.bounds),kWidth),
kWidth,
kWidth)];
[btn setBackgroundColor:[UIColor
redColor]];
[self.view
addSubview:btn];
[btn addTarget:self
action:@selector(onBtnTouchUpInside:)
forControlEvents:UIControlEventTouchUpInside];
UIBezierPath *maskPath = [UIBezierPath
bezierPathWithRoundedRect:btn.bounds
byRoundingCorners:UIRectCornerBottomLeft|
UIRectCornerBottomRight cornerRadii:CGSizeMake(10.0,
10.0)];
CAShapeLayer *maskLayer = [CAShapeLayer
layer];
maskLayer.frame = btn.bounds;
maskLayer.path = maskPath.CGPath;
btn.layer.mask = maskLayer;
alloc] initWithFrame:CGRectMake(PhaseHalf(CGRectGetWidth(self.view.bounds),kWidth),
PhaseHalf(CGRectGetHeight(self.view.bounds),kWidth),
kWidth,
kWidth)];
[btn setBackgroundColor:[UIColor
redColor]];
[self.view
addSubview:btn];
[btn addTarget:self
action:@selector(onBtnTouchUpInside:)
forControlEvents:UIControlEventTouchUpInside];
UIBezierPath *maskPath = [UIBezierPath
bezierPathWithRoundedRect:btn.bounds
byRoundingCorners:UIRectCornerBottomLeft|
UIRectCornerBottomRight cornerRadii:CGSizeMake(10.0,
10.0)];
CAShapeLayer *maskLayer = [CAShapeLayer
layer];
maskLayer.frame = btn.bounds;
maskLayer.path = maskPath.CGPath;
btn.layer.mask = maskLayer;
相关文章推荐
- YUI Compressor使用配置方法 JS/CSS压缩工具
- iOS7中计算UILabel中字符串的高度
- iOS-Core-Animation-Advanced-Techniques(六)
- iOS-Core-Animation-Advanced-Techniques(四)
- iOS-Core-Animation-Advanced-Techniques(一)
- 【xib】加载的一些问题,以UICollectionView 为例
- ContentResolver query 参数详解
- 【EasyUI】——EasyUI的布局
- iOS 中如何除去UIAlertView 规避delegate对象销毁后接收消息的crash
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- Android UI 之一步步教你自定义控件
- AFJSONRequestSerializer
- ORA-02287: sequence number not allowed here解决
- ios NSURLSession completeHandler默认调用quque
- Repeated DNA Sequences
- iOS开发UI篇—Quartz2D使用(绘图路径
- 关于requirejs框架添加时间戳问题
- POJ-1503 Integer Inquiry
- 探秘Java中String、StringBuilder以及StringBuffer
- 转载priority_queue用法总结