2017-05-11 84 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

謝謝^^謝謝! –