close

通常我們要Button 或是 View 要圓角的時候我們都直接

[view.layer setCorerRadius:8.0f]

但這個方法是讓四邊都是圓角

若是只想要某一個角是圓角要怎麼做呢

UIBezierPath *maskPath;

maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds

                                         byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)

                                               cornerRadii:CGSizeMake(8.0, 8.0)];

        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

        maskLayer.frame = view.bounds;

        maskLayer.path = maskPath.CGPath;

        view.layer.mask = maskLayer;


UIRectCornerTopLeft               左上圓角

UIRectCornerTopRight            右上圓角

UIRectCornerBottomLeft         左下圓角

UIRectCornerBottomRight       右下圓角



arrow
arrow
    文章標籤
    UIBezierPath ios CorerRadius
    全站熱搜
    創作者介紹
    創作者 Mr.Lin 的頭像
    Mr.Lin

    Mr.Lin

    Mr.Lin 發表在 痞客邦 留言(0) 人氣()