ios設置左上和右上爲圓角

// 左上和右上爲圓角

        UIBezierPath *cornerRadiusPath = [UIBezierPath bezierPathWithRoundedRect:self.teLabel.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(5, 5)];

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

        cornerRadiusLayer.frame = self.teLabel.bounds;

        cornerRadiusLayer.path = cornerRadiusPath.CGPath;

        self.teLabel.layer.mask = cornerRadiusLayer;

 

要設置其他角的圓角,可以修改byRoundingCorners:

 UIRectCornerTopLeft     = 1 << 0, // 左上
    UIRectCornerTopRight    = 1 << 1, // 右上
    UIRectCornerBottomLeft  = 1 << 2, // 左下
    UIRectCornerBottomRight = 1 << 3, // 右下
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章