I have the following Image asset defined (FSDirectButton)...
How do I specify a button to use this as it's image in the Xamarin xib designer?
When I choose the Image option in the properties window all I see are images that are stored in my Images folder.
I inherited this app which was originally done in a older version of Xamarin iOS, so not sure if that is affecting things or not...
However I want to use the image asset library for my buttons, but I am not sure how to specify in the designer which image to use? Or do I have to do it runtime in code?
Look at this video. It can help you, but raise some new bug. Enjoy
Also you can set the Image from Asset catalog in your ViewDidLoad() method.
For example:
//get image set from asset catalog
var imageFromBunde = UIImage.FromBundle("ImageSet"); //ImageSet - name of your image set in Asset catalog
myImage.Image = imageFromBundle;
Related
My application has one of these files but it doesn't seem to do anything and when I click on it, then it shows as empty.
That is an Asset Catalog Image Sets
Asset Catalog Image Sets - Use Asset Catalog Image Sets to manage and
group all version of a given image asset required by an app.
You can add images to your iOS solution, using Resources, or creating a Catalog Image Set.
You can read the official Apple Documentation
There is no default file called Styles.xcassets in the iOS project. And I think this is a normal Asset Catalog Image Sets file created by someone.
In an iOS project, the is a default Asset Catalog Image Sets called Assets.xcassets file and manager your image there.
Also, instead of using the Assets.xcassets, you can create more ....xcassets to manager your images. It can be more clear and is easier to distinguish different kinds of images.
For example, if there is a Styles.xcassets, you can put all images of style into this file. You can also create a Home.xcassets there to put all images in the homePage there.
Hope you understand What's a Styles.xcassets file in the iOS project used for now.
I have worked on extensions and it's all very interesting. For all type of extensions, icons work really well except for Action Extension where the icon is all white? Do you know how to create an icon for Action Extension?
In the Build Phases of your Extension Settings, just add Images.xcassets (or the icon file) to the Copy Bundle Resources.
PS: For Action Icon, any color data in the image itself is ignored. via Apple Docs
The alpha channel of the image is used as a mask to generate the final
image that is presented to the user. Any color data in the image
itself is ignored.
I had to manually add my icon assets catalog in the build settings. I described it here:
To get this to work with my existing Asset Catalog, I had to add the following to the extension's Build Settings:
The name of the set in my Assets Catalog is "ExtIcon". I had tried setting the CFBundleIcon and the NSExtensionServiceToolbarIconFile keys in the info.plist for the extension, but had no luck. This actually seems to make sense since it is the same way that icon sets are linked to the container app, not via info.plist, but via the Build Settings.
My app icon is just a grey super ellipse even though I have specified a icon asset catalog in my Targets App Icons and Launch Images.
The following worked for me creating a Share Extension, but I believe Action Extension will do the same. Note that in the case of an Action extension, you need a monochromatic version.
If you are using an asset catalog for your main application icon, you should be able to get the Extension to leverage that same asset catalog. The key for me was to:
Select my extension and tell it to use Asset Catalog. Select the same catalog your main icon is using. The default should be AppIcon
Select the image.xcassets file in XCode Project Navigator
Check my extension so that it is included in the Target Membership
Your asset catalog in your main application isn't accessible from your application extension as they are two separate applications bundles that can only share Frameworks.
You will need to create a separate asset catalog in your action extensions folder and reference that one in your Targets.
EDIT: This worked for me for iphone but not for ipad simulator. Making new images (60x60 and 76x76) with only black and white solved it.
Add the image.xcassets to the extension target
While developing a project for Windows Phone 7, I'm adding an image control onto the Grid and using the following code in C# to set the image source:-
Uri nUri = new Uri("/TestImage.png", UriKind.Relative);
BitmapImage nBitmapImage = new BitmapImage(nUri);
FacebookImage.Source = nBitmapImage;
The problem is that whenever I use custom images, they do not show up when I build and run the app on the emulator. Whereas, if I change the image file name in the above code to one of the images that are included in the project by default (ApplicationIcon.png), the image shows up upon running. I would like to know if this is a problem with the code or with the custom image files I'm using. I'm ensuring that the images I'm creating are proper and have the same attributes as the images included by default.
Could someone please help me out with this.
Thanks.
Click on your custom picture in Visual Studio's Solution Explorer. Then, look at the property window (press F4 if it's closed), and at the "Build Action" line. It basically tells the compiler how to embed your file in the application. The build action of ApplicationIcon.png should be "Content", just set the same one for your custom pictures.
I Created a monotouch project, add add new files: images/abcd.png(build action:content) into my project. when open the mainUI.xib, In xcode(4.2) Interface Builder design-time, I manually set the image property with the value "images/abcd.png", but it won't show up until run time.
I know this is a known limitation of MonoDevelop and Interface Builder, but I want to use the image as a background pic to layout my UI in design-time , how can I do?
Environment: XCode4.2+MontoDevelop2.8.6.4+Montotouch 5.2
in MonoDevelop go project options -> iPhone Application -> Advanced
add image to Icon files section.
select image in design time, then you will see image at run time.