How can I set image to UIImage
object.
For example:
UIImage *img = [[UIImage alloc] init];
[img setImage:[UIImage imageNamed:@\"anyImageName\"]]
Like vikingosgundo said, but keep in mind that if you use [UIImage imageNamed:image]
then the image is cached and eats away memory. So unless you plan on using the same image in many places, you should load the image, with imageWithContentsOfFile:
and imageWithData:
This will save you significant memory and speeds up your app.