Drawing in iOS - Part 4: Paths and | Ray Wenderlich Videos

Learn how to construct paths and position CALayers


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4659-drawing-in-ios/lessons/4

Hi Caroline. Thank you so much for this valuable course. The download materials for Part4 only has the png files and no playground. Please correct me if this is how it is supposed to be :). Thanks

@d4devil - I’m glad you’re enjoying the course :smiley: - thank you for letting us know - it should be fixed now.

Thanks for the great course, Caroline, really helpful! I’ve got two questions though:

  1. In your example you create a new shape layer and add it to the main layer as a subview. Could we, as an alternative, override the view’s main layer property, return a CAShapeLayer and work with that?
  2. When you create the shape layer, it starts off undefined size-wise with a frame / bounds of CGRect.zero and should actually be invisible (if I got the notion behind it right). Is it because we’re working in a playground that the layer still shows up, before you give it a fixed frame?

Would be glad for some clarification :slight_smile:

  1. Yes, but you’d have to subclass the UIView:
class View: UIView {
  override class var layerClass: AnyClass {
      return CAShapeLayer.self
  }
}

let shapeLayer = view.layer as! CAShapeLayer
  1. It’s been a long time since I made these :slight_smile: - does the layer show up? This layer doesn’t:

Screen Shot 2019-12-18 at 4.07.11 pm