自定义切圆角 IOS
2015-05-23 09:07
218 查看
NSMutableAttributedString *attString = [[NSMutableAttributedStringalloc]
initWithString:@"进击的巨人"];
NSShadow *shadow = [[NSShadowalloc]init];
shadow.shadowColor = [UIColordarkGrayColor];
shadow.shadowBlurRadius =1;
[attString setAttributes:[NSDictionarydictionaryWithObjectsAndKeys:shadow,NSShadowAttributeName,nil]
range:NSMakeRange(0, attString.length)];
UILabel *l = [[UILabelalloc]init];
l.frame =CGRectMake(240,160,
100, 30);
l.backgroundColor = [UIColorclearColor];
l.attributedText = attString;
[selfaddSubview:l];
-(void)createUI{
UIBezierPath *maskPath = [UIBezierPathbezierPathWithRoundedRect:_codeBtn.boundsbyRoundingCorners:UIRectCornerTopLeft
|UIRectCornerBottomLeft cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer = [[CAShapeLayeralloc]
init];
maskLayer.frame =_codeBtn.bounds;
maskLayer.path = maskPath.CGPath;
_codeBtn.layer.mask = maskLayer;
UIBezierPath *maskPath1 = [UIBezierPathbezierPathWithRoundedRect:_coutryBtn.boundsbyRoundingCorners:UIRectCornerTopRight
|UIRectCornerBottomRight cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer1 = [[CAShapeLayeralloc]
init];
maskLayer1.frame =_coutryBtn.bounds;
maskLayer1.path = maskPath1.CGPath;
_coutryBtn.layer.mask = maskLayer1;
UIBezierPath *maskPath2 = [UIBezierPathbezierPathWithRoundedRect:_phoneNo.boundsbyRoundingCorners:UIRectCornerTopLeft
|UIRectCornerBottomLeft cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer2 = [[CAShapeLayeralloc]
init];
maskLayer2.frame =_phoneNo.bounds;
maskLayer2.path = maskPath2.CGPath;
_phoneNo.layer.mask = maskLayer2;
UIBezierPath *maskPath3 = [UIBezierPathbezierPathWithRoundedRect:_sendBtn.boundsbyRoundingCorners:UIRectCornerTopRight
|UIRectCornerBottomRight cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer3 = [[CAShapeLayeralloc]
init];
maskLayer3.frame =_sendBtn.bounds;
maskLayer3.path = maskPath3.CGPath;
_sendBtn.layer.mask = maskLayer3;
// _testLabel.layer.masksToBounds = YES;
// _testLabel.layer.cornerRadius = 5;
//
// _sumbitLabel.layer.masksToBounds = YES;
// _sumbitLabel.layer.cornerRadius = 5;
[cell.imageHeader
setContentScaleFactor:[[UIScreen
mainScreen] scale]];
cell.imageHeader.autoresizingMask =
UIViewAutoresizingFlexibleHeight;
cell.imageHeader.contentMode =
UIViewContentModeScaleAspectFill;
cell.imageHeader.clipsToBounds =
YES;
}
initWithString:@"进击的巨人"];
NSShadow *shadow = [[NSShadowalloc]init];
shadow.shadowColor = [UIColordarkGrayColor];
shadow.shadowBlurRadius =1;
[attString setAttributes:[NSDictionarydictionaryWithObjectsAndKeys:shadow,NSShadowAttributeName,nil]
range:NSMakeRange(0, attString.length)];
UILabel *l = [[UILabelalloc]init];
l.frame =CGRectMake(240,160,
100, 30);
l.backgroundColor = [UIColorclearColor];
l.attributedText = attString;
[selfaddSubview:l];
-(void)createUI{
UIBezierPath *maskPath = [UIBezierPathbezierPathWithRoundedRect:_codeBtn.boundsbyRoundingCorners:UIRectCornerTopLeft
|UIRectCornerBottomLeft cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer = [[CAShapeLayeralloc]
init];
maskLayer.frame =_codeBtn.bounds;
maskLayer.path = maskPath.CGPath;
_codeBtn.layer.mask = maskLayer;
UIBezierPath *maskPath1 = [UIBezierPathbezierPathWithRoundedRect:_coutryBtn.boundsbyRoundingCorners:UIRectCornerTopRight
|UIRectCornerBottomRight cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer1 = [[CAShapeLayeralloc]
init];
maskLayer1.frame =_coutryBtn.bounds;
maskLayer1.path = maskPath1.CGPath;
_coutryBtn.layer.mask = maskLayer1;
UIBezierPath *maskPath2 = [UIBezierPathbezierPathWithRoundedRect:_phoneNo.boundsbyRoundingCorners:UIRectCornerTopLeft
|UIRectCornerBottomLeft cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer2 = [[CAShapeLayeralloc]
init];
maskLayer2.frame =_phoneNo.bounds;
maskLayer2.path = maskPath2.CGPath;
_phoneNo.layer.mask = maskLayer2;
UIBezierPath *maskPath3 = [UIBezierPathbezierPathWithRoundedRect:_sendBtn.boundsbyRoundingCorners:UIRectCornerTopRight
|UIRectCornerBottomRight cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer3 = [[CAShapeLayeralloc]
init];
maskLayer3.frame =_sendBtn.bounds;
maskLayer3.path = maskPath3.CGPath;
_sendBtn.layer.mask = maskLayer3;
// _testLabel.layer.masksToBounds = YES;
// _testLabel.layer.cornerRadius = 5;
//
// _sumbitLabel.layer.masksToBounds = YES;
// _sumbitLabel.layer.cornerRadius = 5;
[cell.imageHeader
setContentScaleFactor:[[UIScreen
mainScreen] scale]];
cell.imageHeader.autoresizingMask =
UIViewAutoresizingFlexibleHeight;
cell.imageHeader.contentMode =
UIViewContentModeScaleAspectFill;
cell.imageHeader.clipsToBounds =
YES;
}
相关文章推荐
- iOS 自定义圆角进度条
- iOS渐变和自定义圆角的实现
- iOS中创建自定义的圆角按钮
- 自定义仿IOS的圆角AlertDialog
- iOS中创建自定义的圆角按钮
- UI:IOS中自定义圆角图片和按钮
- 源码推荐(8.17):闪屏效果,简易动画引擎,iOS UIView自定义四个边角的圆角
- iOS进度条 自定义圆角 UIProgressView
- [iOS]自定义 TableViewCell 实现圆角/渐变色 TableView
- 在IOS中如何读取系统产生的plist文件和自定义的plist文件
- 【iOS沉思录】iOS添加自定义字体详解
- 自定义View之圆形圆角椭圆进度条等
- iOS 自定义协议
- iOS开发笔记--如何自定义启动画面Default.png加载时间
- ios tableview 那些事(二十一) 使你的自定义tableviVCells 更加平滑
- iOS开发自定义时间选取器
- IOS开发——自定义手势(拖动UIPanGestureRecognizer)
- iOS项目开发实战——配置自定义动画
- IOS如何给VIEW设置2个圆角?set cornerRadius for only top-left and top-right corner of a UIVIEW
- IOS开发-16.自定义不等高cell