I have a simple application which I've added a custom line chart to. While drawing this chart in on of my UIViews everything is fine, but when I added the chart to a simplified view I suddenly experience a situation where all the text I draw is clear/not present.
There are some static variables involved because of the way the animations need to be handled (iOS/Android/Web) compatibility in the algorithm so the full example is rather complex.
To explain this I added a simple drawing method at the end of my CALayer.draw override
//TEST CODE
let box = CGRect(x: 0, y: 0, width: 100, height: 100)
let textToDraw = "I AM A TEST"
let font = UIFont.boldSystemFont(ofSize: 10)
let boxSize = fontSize.space
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .right
let attrs = [
NSFontAttributeName: font,
NSParagraphStyleAttributeName: paragraphStyle,
NSForegroundColorAttributeName: UIColor.black
]
ctx.setStrokeColor(UIColor.orange.cgColor)
ctx.beginPath()
ctx.move(to: CGPoint.zero)
ctx.addLine(to: CGPoint(x: box.width, y: box.height))
ctx.addLine(to: CGPoint(x: box.origin.x + box.width, y: box.origin.y + box.height))
ctx.strokePath()
// print("fontSize:\(fontSize) string:\(textToDraw)")
//textToDraw.draw(with: offset , options: .usesLineFragmentOrigin, attributes: attrs, context: nil)
textToDraw.draw( in: box, withAttributes: attrs)
However, and this is frustrating, if I visit the OTHER view where the chart draws (or any other custom drawings happens) I end up with this:

I'm having trouble tracing this down and I have a (justifiably) annoyed client.
The Code for "reloading the view" is basically view.dismiss(animated:true)
followed by a
performSegue("brokenView")
Has anyone run into this behavior before? Are there any pointers you can offer to getting the text to stick. I'm at the point I'm debating dropping a hidden UIView with drawing on my home screen to fix it but there has to be a better way.
The orange lines were put in to verify that my "bounding boxes" were not off the screen.
The layer in question is basically this: