I would like to load a sample image in an IB designable UIImageView, to be shown in Interface Builder while editing the interface. The following code does not w
UIImageView
For Swift 4 (and 3) use this:
let image = UIImage(named: "foo", in: Bundle(for: type(of: self)), compatibleWith: traitCollection)
This approach gets the bundle universally