I am writing the app using latest Swift 4.1.2 and Xcode 9.4.1 for iOS 11.4. So I want to use vector images in my app in PDF format. I made the simple app which showing the problem, please, look:
This app only show only one image, but if you rotate the screen, rendering happens and picture becomes beautiful.
So the question is: how to force Xcode render vector images in Main.storyboard without touching the code? So app upload already rendered images?
Go to -> Images.xcassets and select the image. From the attributes inspector, make sure that preserve vector data is checked as following:
I hope it solves your problem.
Xcode 9 changes situation for vector data by allowing you to choose to treat the image as a vector at runtime. This means the image can smoothly scale to arbitrary sizes. The only change you need to make is to tick Preserve Vector Data for the PDF image in the asset catalog.
Related
From Apples documentation I read:
An alternative to creating bitmap images is to use template images or symbol images instead. Template images specify the shape you want to draw, but not the associated color information. Symbol images are similar to template images but are vector based, so they scale to different sizes. Both types of images simplify the process for supporting Dark Mode. They also reduce the number of image assets you must ship with your app.
Do I understand this correct that I can not use a vector based symbol image set as a replacement for bitmap but scalable?
Update
My situation:
I've an Image Set in my iOS project. There I can add three bitmaps for the three scaling options iOS devices support. Those images must be of type *.png
Now I would like to replace those three bitmaps with a single vector graphic file *.svg. This seems not possible. If I want to use vector graphic images I've to add another asset type called "symbol image set" (Xcode -> Editor -> Add Assets -> New Symbol Image Set).
So far so good but now my question. Those "symbol image set" assets only the the shape but not the color information into account. That's why I would like the "old" way where the color information is taken into account but the file being a vector graphics file (*.svg).
You don't actually need a Symbol Set for what you are trying to achieve.
All you need is a vector image in pdf format, marking it as Single Scale
Then, you can mark the asset as template (meaning you can tint it with any color) or original if you want to retain its original colors.
Finally, note that although you supply vector images, Xcode by default will produce png versions for all scales behind the scenes. If you need to preserve the vector data (which can help in some cases where you need to upscale) you can enable Preserve Vector Data as well.
Found new option on xcasset catalogue image property in Xcode 10 called "Auto Scaling".
What does this property do?
Is it in any way related to Resizing: "Preserve Vector Data" when using PDF vector assets?
It looks like this may only be used by WatchOS.
From https://developer.apple.com/documentation/watchkit/supporting_multiple_screen_sizes?language=objc
Alternatively, in watchOS 5 and later, you can provide scalable PDF assets. Add a PDF as a 2x image asset, then set its Auto Scaling attribute to Automatic. When you load the PDF, the system scales the image based on the current device’s screen size as listed in the table. This allows you to provide a single asset for all four screen sizes.
I'm not sure if this works on iOS as well. I was unable to find any mention of auto scaling outside of this WatchKit documentation.
We used to have an option "Always use Y-Up axis" toggle in Xcode (until Xcode 7 at least, I think).
It's gone in current Xcode 8.2.1, and probably gone since 8.1 or even 8.0. Why? Or is it hiding somewhere else? Any workarounds?
Update: I found a related quote from a WWDC speech, way back in 2014:
The way you add 3D assets to your game is just SceneKit asset
catalogs.
SceneKit asset catalogs are new feature in Xcode 6, SceneKit asset
catalogs are new feature in Xcode 6, and they allow you to organize
and optimize your 3D assets.
The structure of SceneKit asset catalogs is preserved when they are
copied into your target.
Also, they automatically track files that are added to them or removed
from them on disc.
They are really convenient because they can optimize your 3D assets
for you.
For instance, they help with up axis conversion.
SceneKit follows the up axis conversion, which means that the positive
y axis is the one that looks up.
This is a convention that is followed by many other applications and
frameworks, but some exporters do things differently and use a z up
axis convention.
With SceneKit asset catalogs, you don't have to think about that.
We automatically and transparently convert all the animations and
geometries in your scene so that they follow the up axis convention.
Taken from http://asciiwwdc.com/2014/sessions/610
Video at https://developer.apple.com/videos/play/wwdc2014/610/
The above seems to describe the scene kit asset catalog when it was introduced. It doesn't actually answer my question here; why that feature is removed from current Xcode. I can also confirm that no conversion happens behind the scenes. A model exported from Blender is always going to move closer to or away from camera if its Y position is changed. At run-time it is the same.
In Xcode 8, you can Ctrl-click on the .scnasset folder and Open As > SceneKit Catalog. If you make any changes, it will write out a Settings.json file. This may be what you are looking for.
I've drawn up an image in Adobe Illustrator CS6. I export/save the image as a PDF. In Xcode, I create an image set and set the scale factor to Single Vector.
Yet when I use the image in my app, it still appears pixilated.
I've used vector images in older versions of Xcode (6.1 & 6.2) and it worked fine. Why is it not working in 6.4?
Try this article. It describes how to save vector image correctly and how to use it in Xcode.
IMPORTANT TO KNOW: Xcode slices your vector image to needed dimension. E.g. if you'll put 50x50 vector image it will create 50x50(x1), 100x100(x2), 150x150(x3) images. So you should to save original vector image for x1 dimension.
If you are testing on the simulator, try testing on an actual device. If you look at the images on all the other apps that are in the simulator, you will notice that they are all pixilated also.
I am in the process of going through a large project and removing unused image assets. I had been using cmd+shift+f to perform a project wide search for given image names. I'd assumed this was working until I realized that if I set an imageview to display an image in interface builder that image reference was not showing up in my search.
Why doesn't the app wide search look for a value within an xib file?
Below is an image in a sample project which recreates the issue. I'm assigning img2 in the xib, but as you can see in the search results img2.png is not found.