Using PDFs for icon images in Xcode 7.2 - ios

I'm attempting to use PDF files as icons in an app I'm working on. The issue I'm encountering is I'm getting inconsistent tint colors.
If I set a button image from interface builder, the icon image shows up black at runtime. Every time. Regardless of what I attempt to set from interface builder.
I tried setting my button icon image via code and instead of showing up black, it's white:
let myGraphicFile = UIImage(named: "myPDFImage")
let myButtonImage = myGraphicFile?.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
myButton.setImage(myButtonImage, forState: .Normal)
From code, regardless of what I attempt to set the tint to, it's always white from code.
I discovered this post relating to Xcode 6.x, but I think it might be dated, as I'm able to partially do it, but I can't set the tint.
Use PDF in XCode for an AppIcon (.appiconset collection)
I create the icons in Inkscape, save as PDF 1.5. I add the file to Images.xcassets. In Images.xcassets' attributes inspector, I'm setting:
Devices to Universal
Scale factor to Single Vector.
Summary: I can get it to show up and scale properly, but it's either black from interface builder or white from code. I suspect I'm missing something re: how to save the file from Inkscape.
Thank you for reading. If you have any suggestions, I welcome them.

I have figured out how to create vector icons with Inkscape. When you use PDFs to display icons in iOS, you need to alter the Attributes Inspector for your icon in xcAssets as follows:
1) Drag the PDF into xcAssets
2) Set devices (I did Universal and it worked fine)
3) If your PDF icon is under 1x, 2x, or 3x size class, drag it to Universal and delete the rest of them.
4) Set Scale Factors to Single Vector.
5) Render as Template Image.
Once it's configured there, then you just treat it was you would any other image in interface builder. It's essentially the same thing I was doing in code, but I don't think it gets done in code...it's gotta be done on xcAssets where the image lives. It's my understanding iOS renders vector images for the size class at run time. I think by attempting to tweak it in code wasn't working because the image had already been rendered.
If anyone has any questions on this, I found this link helpful in resolving my issue.
Additionally, this post covers the topic, too. https://stackoverflow.com/a/25804358/4475605

Related

Image suggestions are not working Xcode 10

I am trying to set image to UIImageView. Its working well in older version.
In Xcode 9.4.1
But in Xcode 10
When I am trying to type name of image, image suggestion is not showing.
Even "Image Literal" is not working. Double clicking on above icon also not working.
Is there any setting in Xcode preferences?
How to enable image suggestion like before?
In Xcode 10 and Swift 4.2, only the code completion function (or auto-complete) of the Xcode IDE has been discontinued for the old way. Here is the new way:
Just type image literal and it will complete with default icon.
Double click on this icon and it will open the media library right side of it.
Just choose your image and it work like before!
Hope I am able to help you!
https://download.developer.apple.com/Developer_Tools/Xcode_10_beta_3/Release_Notes_for_Xcode_10_beta_3.pdf
Code Completion for Swift image literals has been removed in Xcode 10. (38087260)
There seem to be some real issues with how Xcode 10 handles image literals, especially when the name you provide your assets doesn't align with the filename of those assets.
The following are the steps I've found will restore image literal previews.
Add an image via the media library picker.
If you have multiple resolutions for your image (e.g. #1x, #2x, #3x), Xcode will inconveniently drop them all into your code and throw an error to let you know you've done something naughty.
Delete two of the faulty image previews, if necessary. You may be left with a default image icon instead of a preview of your actual image.
Comment out the lines on which you're setting the image. You'll see the image literal references the filename of your asset rather than the name you've provided in the asset catalog.
If you've renamed your assets after adding them to your asset catalog, this seems to sometimes prevent Xcode from reading the asset appropriately.
Change the filenames to the appropriate asset names.
You can find the asset names in your asset catalog.
Uncomment the code and, if the default image icon is still visible, double click on the image icon. It should then display a preview of your actual asset.
You may also need to clean and rebuild your project.
use command + shift + M to popup the Media Library then Simply Drag and Drop into your Code
OR

ImageView in Xamarin.iOS LaunchScreens: Set image

I want to change/set the image in my launch screen for my Xamarin.iOS App.
Opening LaunchScreen.storyboard in my Visual Studio 2017 (Win10), I get the storyboard editor as expected.
But if I want to change (or even set) the Image-Property of the default ImageView (or a newly added one), the default file open dialogs comes up - and no matter what image file I select, nothing changes.
Do the images for the launch screen storyboard comply some criteria? e.g. filetype? location?
Update:
This is the property I try to set with an image:
As files I tried several PNG images - all working well as images in my normal Xamarin Views or as Icons.
I think your problem is that you can try this way,rebuild your project when you create a new xarmain.ios project.
Try the following steps

UITabBar Large Content Size Image (HUD) doesn't display in Large Text mode

iOS 11 has an accessibility feature that shows a large version of a tabbar icon in a pop-up HUD when long pressed. In a WWDC presentation, it was mentioned this just involves turning on:
Settings -> General -> Accessibility -> Larger Text
..and adding:
tabBarItem.largeContentSizeImage = UIImage(named: "myHud")
Alternatively, you can add a vector image as the main tool-bar image, with 'Preserve Vector Data' checked in the asset catalog.
I've tried all combinations of this, and a long press does not show the HUD. I also tested with the Files app on my iPad running iOS 11b4 with no luck. This is the app that was demoed at WWDC.
Is there some other accessibility setting I'm missing to enable this feature? Or is it not available in beta 4?
It isn't enough to turn on Larger Text. You also have to use Larger Text — i.e. slide the slider way to right.
Then it works — well, the HUD appears. But the icon is not being enlarged within the HUD, so I don't quite see the point:
(As you can see, I'm doing this in a test project where I'm experimenting with the vector PDF image feature.)
This feature implementation and an example with tab bar are perfectly explained with illustrations on this accessibility site but here are the outlines :
Under Xcode, import the image to be enlarged with a pdf extension and a x1 resolution in the xcassets catalog.
In the new Image Set, tick Preserve Vector Data and specify Single Scale as Scales attribute.
If a storyboard is used for this image, tick Adjusts Image Size in the Image View section, otherwise put the adjustsImageSizeForAccessibilityContentSizeCategory image property to true in code.
For your tab bar or tool bar used in the application, first repeat the previous 3 steps for each image included in the items to be enlarged in the middle of the screen and then link the accessibility image to its appropriate item.
This feature is available only for the accessibility text sizes.
WARNING : don't forget to check your layout with these new images larger sizes.
For your record, an explanation of the Large Content Viewer is provided in this detailed WWDC video summary if need be ⟹ the UILargeContentViewerItem protocol is an iOS 13 new feature that shows the same HUD that's shown for standard bar items.
You need to go :
Settings > General > Accessibility > Larger Text(set on) > Move slider more then half to the right
Don't forget to set
tabBarItem.largeContentSizeImage = someKindOfImage
And Long press will does the trick.

Xcode Deployment Info and icons using CMake

I've tried looking for info on how to set these (in red) using CMake but have had no luck so far:
1st red box issue:
First of all, even though the device seems like it's been set to 'Universal' correctly, the value isn't being interpreted correctly by Xcode. When I set it to 'Universal' manually using the dropdown, it gives a tab each for iPhone and iPad. Furthermore, I know it's not being interpreted correctly as the app does not function correctly (in my case, neither the launch image nor the app itself run full screen).
I don't think setting orientation programmatically is an option for me since I need the launch image in the correct orientation as well.
So can't do something like this:
How do I programmatically set device orientation in iOS7?
2nd red box issue:
I use an asset file for all my icons, so at the moment I'm having to build using CMake and then press 'Use Asset Catalog' each time.
I found this but doesn't seem very useful:
http://cmake.3232098.n2.nabble.com/Icon-and-Launch-image-support-for-iOS-apps-td7590970.html
Regarding the "1st box issue", I've found that the approach taken by this demo project works really well.
https://github.com/forexample/testapp/blob/master/CMakeLists.txt
They use a templated Info.plist to inject the bundle identifier, etc, during configure. The nice part is then you can modify the orientations in the plist.in file, and then these get translated cleanly to the Info.plist once you open the project.
Regarding the 2nd red box issue, i found that the attribute I needed to set was XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME
For example:
set_target_properties(${TARGET} PROPERTIES
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
For Launch Images I got it to work by setting it in the plist.in file under UILaunchStoryboardName as described in yano's previous answer.

ios - UITabBar images are not rendering on the emulator

I have an image that looks like this:
I am trying to make it render on the UITabBar and here is what I did. I went in XCode to File --> Add Files to Project, then I chose the files I wanted and they got added.
Then when I clicked on the files, on the right side of the screen, under "target membership" the checkbox was checked.
But when I added the file name to the UITabBar item, the emulator showed a blank rectangle instead of just empty space...so it recognized the image...but it didn't render that image.
Would someone happen to know what I did wrong? Are the dimensions of the image supposed to be rectangle or square? I have 48x48 square png file.
Can you check your image info?
These are the guidelines for UITabBar image:
30x30 (48x32)
PNG
Anti-aliased
Transparency set
Custom Icon and Image Creation Guidelines

Resources