What is the difference between UIImage
and UIImageView
? Can someone explain it with an example?
UIImage
objects store data from an image (i.e. data from a png file)
UIImageView
objects are used to display a UIImage
UIimage
is an Object which stores data (Jpg, png...)
and UIImageView
class which contains UIImage
as a property.
UIImageView
can have multiple UIImages
, and UIImage
is immutable.
That bothered me a long time ago, when you create an image you do:
var image: UIImageView!
But when you execute that "image" you do
image.image = UIImage.init(named: "image")
Its really easy, you use UIimageView
, to create an image with UIImage
.
UIImage
displays the image, and UIImageView
is a container for that UIImage
.