Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share image resources between app and today widget

Can I share resources (images that are compiled into the application) between my main iOS app and my today extension widget? Say I create a new application. Then add a today extension project to the solution. And then I create a UIImageView. I want to reference an image from a shared pool of images rather than having 2 of every image, one added to main app and another added to widget app.

imageView.Image = UIImage.FromBundle("IMG_3799.JPG");

The IMG_3799.JPG is inside the main application in the References folder of that project. I'd prefer the same image asset to be referenced by the widget. Is that possible? Currently, i'm making a 2nd copy of IMG_3799.JPG and putting it into the widget.

like image 877
LampShade Avatar asked Dec 01 '25 11:12

LampShade


1 Answers

I'm afraid this might be late. Following is what I did with Xcode 12.4

First, go into your Assets.xcassets file in Xcode then select the image you want to be shared. Second, click "Hide or show the Inspectors" in the top right corner of Xcode. Thir, click "Show the file inspector" Then you should see Target Membership where you can simply click the checkbox to have the images to be used in main app, extensions, etc.

I found this method for Wigetkit from 17:10 of this youtube video: https://www.youtube.com/watch?v=ZzBBDrFNXmk

like image 130
ji sung Choi Avatar answered Dec 03 '25 03:12

ji sung Choi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!