2017-05-11 5 views
0
UIBezierPath *maskDefault = [UIBezierPath bezierPath]; 
[maskDefault moveToPoint:CGPointMake(0.0, 0.0)]; 
[maskDefault addLineToPoint:CGPointMake(width, 0.0)]; 
[maskDefault addLineToPoint:CGPointMake(width, height * 0.8)]; 
[maskDefault addLineToPoint:CGPointMake(width * 0.8, height)]; 
[maskDefault addLineToPoint:CGPointMake(width * 0.2, height)]; 
[maskDefault addLineToPoint:CGPointMake(0.0, height * 0.8)]; 
[maskDefault closePath]; 

CAShapeLayer *maskingDefulatLayer = [CAShapeLayer layer]; 
maskingDefulatLayer.path = maskDefault.CGPath; 

CAShapeLayer *maskingLayer = [CAShapeLayer layer]; 
maskingLayer.path = maskDefault.CGPath; 

self.uiView.layer.mask = maskingDefulatLayer; 

두 번째 이미지와 같이 아래쪽 테두리를 제거하고 싶습니다.UIView 아래쪽 테두리 제거 방법?

enter image description here

enter image description here

답변

0

사용이 코드를 대체하는 데 도움이 :

UIBezierPath *linePath = [UIBezierPath bezierPath]; 
    [linePath moveToPoint:CGPointMake(width * 0.2, height)]; 
    [linePath addLineToPoint:CGPointMake(0.0, height * 0.8)]; 
    [linePath addLineToPoint:CGPointMake(0.0, 0.0)]; 
    [linePath addLineToPoint:CGPointMake(width, 0.0)]; 
    [linePath addLineToPoint:CGPointMake(width, height * 0.8)]; 
    [linePath addLineToPoint:CGPointMake(width * 0.8, height)]; 

    CAShapeLayer *lineShapeLayer = [CAShapeLayer layer]; 
    lineShapeLayer.path = linePath.CGPath; 
    lineShapeLayer.strokeColor = UIColor.redColor.CGColor; 
    lineShapeLayer.fillColor = UIColor.blueColor.CGColor; 
    lineShapeLayer.lineWidth = 5.0; 

    [self.uiView.layer addSublayer:lineShapeLayer]; 

    //Bottom white line 
    UIBezierPath *bottomLinePath = [UIBezierPath bezierPath]; 
    [bottomLinePath moveToPoint:CGPointMake(width * 0.2, height)]; 
    [bottomLinePath addLineToPoint:CGPointMake(width * 0.8, height)]; 

    CAShapeLayer *bottomLineShapeLayer = [CAShapeLayer layer]; 
    bottomLineShapeLayer.path = bottomLinePath.CGPath; 
    bottomLineShapeLayer.strokeColor = UIColor.whiteColor.CGColor; 
    bottomLineShapeLayer.lineWidth = 5.0; 

    [self.uiView.layer addSublayer:bottomLineShapeLayer]; 
+0

감사합니다. 소스 코드는 첫 번째 이미지를 다시 나타냅니다. 나는 나의 출처를 가지고 싶다. –

+0

코드를 제거하면 남아있는 두 번째 이미지가됩니다. 그리고 배경색으로 최종선을 그리는 해답을 업데이트합니다. –

+0

谢谢 ^^ 고마워요! –