項(xiàng)目需要畫個(gè)曲線如何做呢?

UIView *viw = [[UIView alloc] initWithFrame:CGRectMake(50, 100, SELF_WIDTH - 100, SELF_WIDTH)];

viw.backgroundColor = [UIColor orangeColor];

[self.view addSubview:viw];

UIView *myCustomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,viw.width, 120)];

myCustomView.backgroundColor = [UIColor whiteColor];

[viw addSubview:myCustomView];

UIBezierPath *bezierPath = [UIBezierPath bezierPath];

[bezierPath moveToPoint:CGPointMake(0, 0)];

[bezierPath addCurveToPoint:CGPointMake(myCustomView.width, 0) controlPoint1:CGPointMake(0, 0) controlPoint2:CGPointMake(myCustomView.width/2, 100)];

[bezierPath addLineToPoint:CGPointMake(myCustomView.width, myCustomView.height)];

[bezierPath addLineToPoint:CGPointMake(0, myCustomView.height)];

[bezierPath closePath];

CAShapeLayer *shapLayer = [CAShapeLayer layer];

shapLayer.path = bezierPath.CGPath;

myCustomView.layer.mask = shapLayer;

myCustomView.layer.masksToBounds = YES;


最后編輯于
?著作權(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)容

  • Quartz2D以及drawRect的重繪機(jī)制字?jǐn)?shù)1487 閱讀21 評(píng)論1 喜歡1一、什么是Quartz2D Q...
    PurpleWind閱讀 908評(píng)論 0 3
  • // // JackDateAndDateView.m // ZHB // // Created by JackR...
    JackRen閱讀 528評(píng)論 0 1
  • 轉(zhuǎn)載;http://www.itdecent.cn/p/bb934ca504d1 1. CAShapeLayer ...
    F麥子閱讀 1,230評(píng)論 0 0
  • 就這樣結(jié)束了的,宣講會(huì)。 我壓力大我也想過(guò)放棄,我還想,自己真的很丟臉。作為一個(gè)學(xué)生會(huì)的副主席,還是團(tuán)隊(duì)的SP,竟...
    大圣叫泥磨閱讀 297評(píng)論 0 0
  • 注冊(cè)好多天了,還加入了一個(gè)小組,打算每天寫一千字,主要的目的是想治療一下我的拖延癥,懶癌等等,因?yàn)檫^(guò)去屢次下定決...
    玫瑰灰閱讀 229評(píng)論 0 1

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