Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load image from Images.xcassets into a UIImage with swift

Tags:

ios

swift

uiimage

I have an image from the Images.xcassets folder and I want to load it into a UIImage programmatically using swift. How can I do this? Anyone done this before? Please give me some code examples!

like image 836
David Avatar asked Aug 22 '15 04:08

David


People also ask

What is the difference between a UIImage and a UIImageView?

UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .


1 Answers

Here's my code:

@IBOutlet weak var imageView: UIImageView!  override func viewDidLoad() {     super.viewDidLoad()     imageView.image = UIImage(named: "Apple") } 

I created an image view and displayed an image inside it.

Enjoy coding!

like image 180
Bright Avatar answered Sep 28 '22 17:09

Bright