I'm trying to create a UIImage View programmatically, I have a new view and I tried doing this
let imageName = "yourImage.png"
yourview.backgroundColor = UIColor.colorWithPatternImage(UIImage(named:imageName))
this did not work because I don't know what this should be yourview in the second line.
Question: How do I make a UIImageView appear on the screen by coding it instead of doing it in the storyboard
UIImage(named:...)
. As the docs say: "If you have an image file that will only be displayed once and wish to ensure that it does not get added to the system’s cache, you should instead create your image usingUIImage(contentsOfFile:...)
. This will keep your single-use image out of the system image cache, potentially improving the memory use characteristics of your app." Just a FYI. – Bushelman