Using custom fonts in Xcode 6 - Swift [duplicate] - swift

This question already has answers here:
Can I embed a custom font in an iPhone application?
(32 answers)
Closed 8 years ago.
I'm new to Swift! I'd like to know how I can use custom fonts in my swift application in Xcode 6.

You just drag the font file (.ttf) into the resources area on the left pane of Xcode.
When you drop it in, a dialog box will appear. Make sure the target for your application checkbox is checked. Then add the following key to your plist:
Fonts provided by application
With the values of the filename "myFont.ttf"
UPDATE (see comment below)
Also make sure the font is added to the Copy Bundle Resources (found under Target -> Build Phases) I just spent about an hour on this, and I was the one who answered this question months ago lol.
UPDATE
Another helpful tip to find the name of the font for the font-family if you are using CSS is to run the following command:
NSLog("Available fonts: %#", UIFont.familyNames());
It prints out all the font name available to the system, including the ones you custom added.

Related

Adding custom fonts to the keyboard extension ios 8

How can I add custom fonts to ios 8 Keyboard extenstion like this.Can anyone have a tutorial or example from which I can refer.Like this example https://itunes.apple.com/us/app/fontkeyboard-for-ios-8-use/id914787397?mt=8
1.In the above link they have the special characters as letters, Please refer below URL
http://fsymbols.com/letters/
2.In Your Extension,You have to maintain the two arrays one is with regular letter (A,B,C,D….)to show on your Keyboard
3.Second one is the Special character that you want to display in your target E.g..,(Ⓐ,Ⓑ,Ⓒ,Ⓓ..) (⒜,⒝,⒞,⒟….)
4.Use can directly copy the special characters from the above reference URL,and then you return the value of selected letter
5.If you want to give an options like the referred app,you need to maintain the array of those letters and return the value that you wanted to display for that selected letter.
Here is the keyboard button action,the insertText method used to insert your text to the target.
Please find my blog on how to creating third-party keyboards :Here's a link
Please find my sample project on github : Simple Custom Keyboard Sample
This is an old question but incase new people need the answer I will add mine. Gagan's answer (above) is quite elaborate and +1 for the github code; however, to my understanding the question is how to add font to custom keyboard, which could mean more than adding special characters to the keyboard keys (Gagan's answer), for example adding letters of languages not supported by apple.
In any case, to add a custom font to iOS keyboard extension, do the following steps:
Step 1. Drag/Add your ttf font to the Keyboard extension folder
(NOT to the host app) of your project in xcode.
Step 2. While importing make sure to check "Copy items if needed" and finish.
Step 3. Select Info.plist under Supporting Files section of the Keyboard extension folder
Step 4. At the end of the list add a string array
called "Fonts provided by the Application" xcode will autocomplete it
for you.
Step 5. Extend the newly added array and add the name of your
font/fonts eg. "Example.ttf"
Step 6. Now to make sure the font is copied to the final binary app, go to project properties and in the Targets section select the keyboard extension, then in the "Build Phases" tab and the "Copy Bundle Resources" subsection add/link the custom font.
That should get you a custom font in your keyboard extension!
Notice that in the steps the Keyboard extension is mentioned repeatedly on purpose, because thats the catching point when adding custom font to the extension compared to adding font to normal applications and it should not be confused with host app of the extension. iOS Custom Keyboard project in xcode usually comprises a host app which is pretty much a normal iOS app and the actual keyboard extension, both are displayed as folders in the Project Navigator.
If the custom font is needed to be used in the host app, then the steps are similar, only then make sure the destination is the host app folder and once again select the host app Target in the project properties when adding to the Bundle resources.

Use old AutoLayout in new XCode Projects? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Remove autolayout (constraints) in Interface Builder
While the answer and final question are the same, the rest of the questions are completely different and the questions that appeared when I searched were unrelated to either question.
In my app, I am trying to set the autoLayout to setup my view properly for iPhone 4 screen size versus the iPhone 5 screensize. With the kind of layout I am dealing with, I really don't need the power provided by the new constraints system and it would be much easier to use the old system. I know this is possible because the older xib files in my project use the old system.
My question is: How do I use the old system in new xib files?
Open your xib file in Xcode, open the right-side pane, select the 1st tab in it, and unselect the "Use auto layout" checkbox.

How do I configure my application icon so that it doesn't appear as a standard iPhone button? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to disable highlighting of the app icon?
Hi all.
In each of my apps, the icon on the iPhone screen gets automatically converted into one of Apple's shiny buttons. I am noticing that some apps have managed to either (a) turned off the shiny appearance (such as Netflix) and/or (b) created an icon set in a transparent background so the image appears to be three dimensional and again, not set in the default shiny button
I have looked through the build settings, but cannot see how to configure. Any ideas?
Thanks.
Please include the below key into your info.plist file.
"icon already includes gloss effects" and make check checkbox as marked.
So, your app icon will be as it is.
Do the following steps.
Open your app's Info.plist file.
Add a new row.
Select the key - Icon already includes gloss effects.
Set YES as the value for that key.

Xcode 4 - removing "Default.png" [duplicate]

This question already has an answer here:
Closed 12 years ago.
Possible Duplicate:
Can't remove Default.png?
I am using Xcode 4, but I am sure the issue does not pertain to this specific IDE.
I have set a "Default.png" using the organizer, but I would like to remove it.
At the time I had already created an image in my project which was no longer being used, instead replaced by the image set in the organizer. I have removed that file, and any "default.png" files from my application (*.app) folders, but the image remains.
How can I get rid of this image?
Do a "clean" of your project.

How to remove the "white reflection" on the application icon? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to disable highlighting of the app icon?
Hi this is an iPhone objective C question.
When I set the icon file for the app, say, icon.png. When it is shown on the phone, a white reflection effect is automatically added on the icon.png
Is there any way to remove te reflection effect? Cause I can see that there are apps without the white reflection effect on the icons
Open your Info.plist file, can also be named ProjectName-Info.plist, and add a new line. The Key-column is a drop down list, click it and scroll through a quite large set of keys in human readable form that are possible to set.
The one you are looking for is called "Icon already includes gloss and bevel effects", that is the human readable form. Writing UIPrerenderedIcon, also works.
Adding this flag will also disable the automatic addition of gloss and bevel in Tunes Store, and on the App Store.
In Xcode 4.3.2 you might also need to define the icons as pre-rendered.
Click on your project on the left, select your target, and under the Summary tab you'll see the App Icons, along with a "Prerendered"checkbox. Check this box and rerun your app.
If the icon hasnt changed yet, you might also need to delete and reinstall (rerun) the app on your device, or perhaps even restart the device, before the new icon is used.
In your info.plist file, add a key called UIPrerenderedIcon and set its value to true.
This will prevent the sdk from automatically adding the glossy shine to your icon