CAShapeLayer offsetting from UIVIew's CALayer -


i'm trying add cashapelayer custom uiviews layer, going well, except fact it's offsetting itself...

it's best explain code , screenshots.. here goes:

all i'm trying achieve simple "slash" cashapelayer in swift 3.

in custom uiview have:

    var slashlayer: cashapelayer? var slashpath: cgpath?  override func layoutsublayers(of layer: calayer) {     if layer == self.layer {         if slashlayer == nil {             slashlayer = cashapelayer()             slashlayer?.bounds = layer.bounds             slashlayer?.strokecolor = uicolor.black.cgcolor             slashlayer?.fillcolor = uicolor.black.cgcolor             slashlayer?.linewidth = 3.0              let slashpath = uibezierpath()             slashpath.move(to: cgpoint(x: layer.frame.minx, y: layer.frame.miny))             slashpath.addline(to: cgpoint(x: layer.frame.maxx, y: layer.frame.maxy))             slashpath.close()              slashlayer?.path = slashpath.cgpath              layer.addsublayer(slashlayer!)         }     } } 

and that's in uiview subclass.

this wind in interface builder (and app when fire up)..

as calayer.layoutmanager isn't around more, how keep layers in line one-another?

screenshot of custom uiview in interface builder - shot 1 screenshot of custom uiview in interface builder - shot 2


Comments