4、畫帶圓角的矩形
?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、畫一個或者兩個或者三個角的原型
?效果圖:
#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];
}