2017-05-11 13 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; 

2番目の画像のように下の枠を削除したいと思います。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

コードを削除すると、残りの2番目の画像になります。そして私は背景色で一番下の線を描く答えを更新します。 –

+0

谢谢^^ありがとう! –

関連する問題