tomkou tomkou - 1 month ago 10
iOS Question

Can not load programmatically Images in Assets Xamarin iOS

I am using Visual Studio for Mac to develop an iOS app. I have create an Asset Catalog for images. When I am trying to add an image to a View in XCode UI designer, it works perfectly : the image sets from Asset Catalog are visible in Image dropdown and if I choose one of them, it is displayed while app runs. However, if I try to set image programmatically using

method, images are not loaded at all. I have already tried to clean, build project, restart Visual Studio and XCode. Should I add the path to the Asset Catalog somewhere (possibly in Info.plist)? Or is there any other way?

Answer Source

button.ImageView is Read-Only.

Try this:

button.SetImage(UIImage.FromBundle("myImage"), UIControlState.Normal);