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

Ich möchte den unteren Rand wie das zweite Bild entfernen.Wie UIView unteren Rand entfernen?

mir helfen

enter image description here

enter image description here

Antwort

0

verwenden Sie den Code zu ersetzen:

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

Dank. aber dein Quellcode reuslt das erste Bild. Ich vermisse meine Quelle. –

+0

Entfernen Sie Ihren Code, es wird das zweite Bild sein. Und ich aktualisiere die Antwort, um eine Grundlinie mit Hintergrundfarbe zu zeichnen. –

+0

谢谢 ^^ danke! –

Verwandte Themen