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

谢谢^^谢谢! –