Also, shouldn’t the x calculation be the following ? var x = min(max(touchLocation.x, minX), maxX)
instead of var x = min(max(touchLocation.x, maxX), minX)
as shown in the video ?
Because that causes a weird behaviour when you pan to the maximum (it comes back to the origin …)
You’re right again @freddyf! Thanks for paying such close attention to the course and the code. It will be a really helpful addition to all the other viewers!
Honestly, I’m going to blame this oversight a little on the fact that the data is fictional so it didn’t LOOK wrong to me. But that’s a great case FOR using real data even in tutorial and example applications!
Quick question regarding drawRect:. I realize this might be a bit more beyond the scope of this course, but curious about performance when it comes to drawing the graph in drawRect: vs creating a new CAShapeLayer and adding it as a sublayer. My understanding is that’s a bit more performant because you can better control when the layer is being redrawn, but not able to find a ton of information around this and was wondering if you had any recommendations for this.
Oh sorry, just saw your response @leamars. I actually just went through the Drawing in iOS course to gain a better understanding. I still have some questions as to when to use core graphics/drawRect: vs when to have a hierarchy of CAShapeLayers (which from what I understand, is faster). Let me ask this question over in that course, though, since I think it might fit better here. I’ll add a link in a bit.