[画带圆角的矩形]UIBezierPath画图基础实例

4、画带圆角的矩形


 1、效果图:


[画带圆角的矩形]UIBezierPath画图基础实例_第1张图片

函数代码:

#pragma mark带圆角的矩形

-(void)drawRoundRectPath{

UIBezierPath*path=[UIBezierPathbezierPathWithRoundedRect:CGRectMake(20,20,self.frame.size.width-30,self.frame.size.height-40)cornerRadius:10];

path.lineWidth=2;

//填充颜色

UIColor*fillColor=[UIColorgreenColor];

[fillColorset];

[pathfill];

//画笔颜色

UIColor*sColor=[UIColorblueColor];

[sColorset];

[pathstroke];

}

2、画一个或者两个或者三个角的原型

 效果图:


[画带圆角的矩形]UIBezierPath画图基础实例_第2张图片

#pragma mark定点个边是圆角的矩形

-(void)drawRoundMoreRectPath{

/**

typedef NS_OPTIONS(NSUInteger, UIRectCorner) {

UIRectCornerTopLeft= 1 << 0,

UIRectCornerTopRight= 1 << 1,

UIRectCornerBottomLeft= 1 << 2,

UIRectCornerBottomRight = 1 << 3,

UIRectCornerAllCorners= ~0UL

};

*/

UIBezierPath*path=[UIBezierPathbezierPathWithRoundedRect:CGRectMake(20,20,self.frame.size.width-30,self.frame.size.height-40)byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRightcornerRadii:CGSizeMake(20,20)];

path.lineWidth=2;

//填充颜色

UIColor*fillColor=[UIColorgreenColor];

[fillColorset];

[pathfill];

//画笔颜色

UIColor*sColor=[UIColorblueColor];

[sColorset];

[pathstroke];

}

你可能感兴趣的:([画带圆角的矩形]UIBezierPath画图基础实例)