代碼切圓角--只切指定的幾個角


UIBezierPath *maskPath=[UIBezierPath bezierPathWithRoundedRect:self.picImageView.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(8, 8)];

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

    maskLayer.frame=self.picImageView.bounds;

    maskLayer.path=maskPath.CGPath;

    self.picImageView.layer.mask=maskLayer;


其中:

byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight


指定了需要成爲圓角的角。該參數是UIRectCorner類型的,可選的值有:

* UIRectCornerTopLeft
* UIRectCornerTopRight
* UIRectCornerBottomLeft
* UIRectCornerBottomRight
* UIRectCornerAllCorners

從名字很容易看出來代表的意思,使用“|”來組合就好了。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章