قالب وردپرس درنا توس
Home / IOS Development / ios – draw # rect core graphics, on top of a layer?

ios – draw # rect core graphics, on top of a layer?



Say you have this in a UIView,

  overrides func draw (_ rect: CGRect) {
la c = UIGraphicsGetCurrentContext ()
c? .setLineWidth (10.0)
c? .move (to: CGPoint (x: 10.0, y: 10.0))
c? .adLine (to: CGPoint (x: 40.0, y: 40.0))
... lots of complicated drawing here, various paths, colors, widths etc ...
c? .strokePath ()
}

Of course, it will pull the hell out of the drawing for you.

But say in the same UIView you do this …

  func setup () {// inits, layout
if zero, etc. {
tingLayer = CAShapeLayer ()
self.layer.insertSublayer (thingLayer, at: 0)
tingLayer.fillColor = UIColor.yellow.cgColor}
tingLayer.frame = borders
let path = ... some fancy path
tingLayer.path = path.cgPath
}

In fact, the new yellow layer above the drawing is drawn in drawing # rect.

How do you draw ̵

1; using kernel graphics commands – either to a layer of things, or maybe to another layer on top of all ??

Core graphics commands:

  light c = UIGraphicsGetCurrentContext ()
c? .setLineWidth (10.0)
c? .move (to: CGPoint (x: 10.0, y: 10.0))
c? .adLine (to: CGPoint (x: 40.0, y: 40.0))
c? .strokePath ()

seems to be moving to a place directly above or on the main track .layer

(Well, that seems to be the case, as far as I can see.)

How to draw you – use core graphics commands – either on thingLayer, or maybe on to another layer on top of everything?

Surely in draw # rect can you specify which cgLayer to draw?

In drawing # rect, can you create another cgLayer and draw to context, the cgLayer?


Source link