[畫帶圓角的矩形]UIBezierPath畫圖基礎(chǔ)實(shí)例

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];

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 基礎(chǔ)知識(shí) 使用UIBezierPath可以創(chuàng)建基于矢量的路徑,此類是Core Graphics框架關(guān)于路徑的封裝。...
    十里桃花不及你閱讀 955評(píng)論 0 5
  • 1.使用UIBezierPath畫圖步驟 創(chuàng)建一個(gè)UIBezierPath對(duì)象 調(diào)用-moveToPoint:設(shè)置...
    翹楚iOS9閱讀 762評(píng)論 1 2
  • UIBezierPath詳解 我在寫本篇文章之前,也沒有系統(tǒng)學(xué)習(xí)過貝塞爾曲線,只是曾經(jīng)某一次的需求需要使用到,才臨...
    白水灬煮一切閱讀 1,281評(píng)論 0 4
  • 當(dāng)流星劃過夜空的一瞬, 我似乎看到了你溫柔的笑魘…… 兒時(shí), 我們牽著手, 嬉戲在田間地頭, 歡笑在村頭巷口。 任...
    花落有情閱讀 371評(píng)論 5 3
  • 書上有句刻在我心里的話。當(dāng)你全心全意去做一件事情,天空中的星星都會(huì)為你排成一線。 可你呀,不知道自己對(duì)于我來說,是...
    w解夏閱讀 291評(píng)論 0 1

友情鏈接更多精彩內(nèi)容