The actual hudView text is specified in LocationDetailsViewController.swift (alpha also works). In HudView.swift text appears as a property, of the view, without declaration. From the docs, image is handled the same way. As implied UILabel and UIImageView objects. One of each per view unless one explicitly adds extra labels and images? Am I understanding this correctly?
The text is not a UILabel here but a String. The image is a UIImage, not a UIImageView. Instead, we directly draw the text string and the image into the view.
I saw that in the book but I couldn’t find reference to text or image (or string) in the documentation for UIView or UIResponder or NSObject. Thanks.
That would be correct. The text
variable is a property (or instance variable) we defined ourselves var text = ""
. The image
variable is a local variable, so it exists only inside that function.
But once we’ve drawn the text and the image on the view, it will keep looking like that, even after the function ends (we simply don’t need these two variables anymore).
OK, I think I see now. text is declared in the class hudView, i.e. it’s a class variable. It doesn’t need to be called text, although it is appropriate. Any name would do, even animal, which works The value of text is set in LocationDetailsViewController.swift on the line: hudView.text = “Tagged”
I’m enjoying the book and learning some useful code. One trick that works for me at least. I’m not a very good typist so I had been copying and pasting from the book(s). I’m learning more now that I type it all out instead.
David