How to use ttf / SVG icons in ios SWIFT 4.0 - ios

As in android, they can use any vector image formats. My designer gave my abc.ttf file which contains icons for the app. The interesting thing about TTF is, it is not stretched or pixelate while increasing the size. So plz help me to figure out, is there any way to use TTF or any other vector image format.
Thnks

Posted my solution at medium.
Refer SVG or TTF icons in iOS (Swift 4.0) without using any third party library.
Step 1: Get your ttf file from the designer or get it online. I am showing with fontAwesome icons.
Link where you get ttf file. : https://fontawesome.com/v4.7.0/
Download this and extract it. You will see the fonts folder in it. Go to fontawesome-webfont.ttf.
Step 2: Open this TTF file and install
After Installation
Step 3: Open to your iOS project, go to your storyboard/Xib file add an UILabel.
Step 4: Add/import TTF file (downloaded) to your project.
Step 5: Now in your attribute inspector, go fonts and choose custom and click on family, you will see a list of fonts.
Choose FontAwesome (or you ttf file name).
That is so easy man. :P
Wait your last step is remaining.
Step 6: (Last One): Open your font file, select icon which you want to use and copy it.
Paste in the text area of your UILable in your storyboard/Xib.
You can use any icon from this file and there is plenty of icons already available at https://fontawesome.com/cheatsheet?from=io. You just need to copy and paste in the text of your label.
Step 1, 2 and 3 are a one-time process for a project and if you want to use the same TTF file in another project as well skip step 1 and 2.
The same procedure goes with buttons.

You can use vector PDFs instead of images
Refer How to use vectors in Xcode

Related

How Can I Make Swift Playgrounds Be Borderless on my iPad?

In Swift playgrounds, I started with an empty playground template (I'm new to playgrounds) and wanted to have the Live View take up the whole screen. I saw this:
Fullscreen for Swift Playgrounds on iPad
Which said to modify a Manifest.plist file but there is no Manifest.plist file in the playground. I also don't see any .playgroundpage file which other people have referenced in other questions for the actual location of the Manifest.plist file.
Where should I put this file? I want it to look like a fullscreen app for context (if the code editor is hidden) and I have a MacBook and iPad which both edit the same file.
I'm using the most up to date version of XCode.
To locate the Manifest.plist
Step 1: Navigate to your playgroundbook from your MacBooks iCloud drive
Step 2: Rightclick and click show package contents
Step 3: Navigate to the playgroundpage folder to find the Manifest.plist you need to change.
Step 4: Edit Manifest.plist change LiveViewEdgeToEdge from NO to YES this will removes the border.
Step 5: To have the Live View take up the whole screen, on the Ipad select the tab between the editor and the live view and drag it, to expand the live view.
After Dragging

How to localize images in iOS if they are set up in a storyboard?

I know how to localize storyboard elements like label, buttons etc. However, I faced a problem where I need to localize the images that were setup in a storyboard in the attribute inspector for the Image View.
Is there a way to localize those without setting those images up in the code, in the viewDidLoad method and calling setImage:[UIImage imageNamed: NSLocalizedString(...)]; ?
Any kind of help is highly appreciated!
I guess I figured it out...maybe not the ideal way of doing it but works for me...
Open image folder in your Project Navigator (panel).
When you click one of the images, on the right (Inspector panel) you'll see the button "Localize".
Clicking on that button gives you a pop-up asking if you want it to be the base (in my case I say yes).
So now in the inspector there're check boxes: Base, language 1, language 2 etc (language n - is the languages you added to your project in the localization settings).
So now if you put a check mark into one of the language check boxes, your image file will have a drop down arrow showing that it has some content inside. If you click that, you'll see how it expands showing the localized files with the name of the language in the () brackets.
However, at this point those files are all the same as the base. So now you need to substitute the base files with the localized ones.
If you right click on the file that needs to be localized, say myImage.png(German), open it in Finder, and replace that file with the right one. Important! The name of the file should stay the same!
I'll post the screenshots later, so it's all clear how to do it.
Using Xcode 9.2
you can achieve it easily like the following
1- From Assets
2- Then you will need to change the Direction option AND CHOOSE BOTH
xcode will allow you to add 3 more image for other language resource
3- add your needed image and use it in story board or from code as well

Localize launch image just for english?

I have a launch image Default-568h#2x.png which I've localized for English (it sits in my en.lproj folder). Now I'd like to produce one other version of that image for every other language (I've removed the english text from it). How would I go about setting this up? I've tried putting an image with the same name in the top directory but that doesn't work. Do I need to rename to something?
Basically, when you localize to any language (eg: Spanish), you will see another folder such as "es.lproj", the Localizable.strings and other localized files will be there.
You may check http://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014
for the step by step instruction on how to do it including localize the image.
Another link that might help: IOS: launch image multiple language
What I did was go into my actual project folder and put the english version of my launch image into a folder called "Launch Image (English)". Then I put the version for the rest of the languages in a folder called "Launch Image (International)" (both images have the exact same name). Then I went into Xcode and attached both folders into the resources section. Then I highlighted each image, clicked on localization in the Utility pane, and for the english version I selected english obviously, and for the other version I selected spanish (then I put a check mark in the check box of each other language in the Utility pane). Then it worked!

How to use different icon size on delphi?

Does anybody knows how to use diferent icons sizes on delphi,
I ask because the windows choose the best icon size when showing on explorer,
But how do I put many icons in different sizes on resource.
Thanks again
Here's how I do it:
Prepare an icon file with an icon editing program. This file is a .ico file and contains multiple versions of the same icon with different sizes and pixel formats.
Reference that icon file in a .rc file that is used as source to the resource compiler.
As part of the compilation, the .rc file is processed, resulting in a .res file.
Link the .res file to the executable with a $R directive.
At runtime load the appropriate version of the icon with one of the Windows API functions that loads images from resources.
I use these steps for all the icons that I use on toolbars and menus. That allows me to have a GUI that scales with the user's font scaling settings. The way that the Delphi IDE leads you to do it is to make a TImageList and fill it up with icons that are stored in the .dfm file. That's pretty hopeless because it doesn't readily allow you to have different sized icons. And it also means that your visual assets are stored in a .dfm file in a great big glob representing all icons. If you want to swap out a single icon, then you can do so but it's rather opaque. The history trail left in your VCS is meaningless beyond any comments you leave.
If you are just talking about the main program icon, then you can add your .ico file to the project in the Project | Options | Application dialog and the IDE will take care of the rest of the details.

how to add to the media library in xcode?

I'm a beginning programmer, so sorry if this sounds stupid. I understand that I have to put the image into Xcode through the media library... but where is the media library? I threw the image file into the folder I made when I created the project but it's not showing up. I have the same image in there in 2 formats: PNG and JPEG. Where is the location of the "Media Library"?
What do you mean with Media Library? The pane in Interface Builder on the bottom right? That just lists all the media items that are part of your current project or workspace.
You have to add the images to your project, if you want to use them in your app. The easiest way is to drag them in one of the Groups in Xcode's Project Navigator tab on the left side. Make sure you check your target (this will make Xcode copy the images into your app's resources on compile time).
If you have the png or jpg, first, you need to create an imageset and then restart xcode, it would be available inside the media library.
To create an image set, you need to select the Assets.xcassets in the left navigation pane, and then in the tool bar select the editor -> Add Assets -> New Image Set. Give a name to your image and select render as Template Image.

Resources