change image programmatically swift

how do i change an image in a uiimageview programmatically in swift

You assign a value to the UIImageView's "image" property. For example if you have "foo.png" in your bundle

imageView.image = UIImage(named:"foo")

First you create a

UIImage
from your image file(s), then create a
UIImageView
from that:
let imageName = "yourImage.png" let image = UIImage(named: imageName) let imageView = UIImageView(image: image!)


Finally, if this applies, you'll need to give

imageView
a frame and add it your view for it to be visible:
imageView.frame = CGRect(x: 0, y: 0, width: 100, height: 200) view.addSubview(imageView)


Are you also considering to use an asset catalog...in other words, how many images?

where should i store the pictures

Try the top/root of the bundle, but again, how many?

100

change image programmatically swift
 
 
Q