4、畫帶圓角的矩形
?1、效果圖:

函數(shù)代碼:
#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、畫一個(gè)或者兩個(gè)或者三個(gè)角的原型
?效果圖:

#pragma mark定點(diǎn)個(gè)邊是圓角的矩形
-(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];
}