How to integrate and use Font Awesome with Objective-C or Swift in an Xcode project?

后端 未结 17 1339
不思量自难忘°
不思量自难忘° 2020-12-12 18:07

So I am trying to use this font http://fortawesome.github.com/Font-Awesome/. I\'ve added the font as a resource and put it in the plist file. Here\'s how I am using it:

17条回答
  •  醉梦人生
    2020-12-12 18:55

    So, I can answer it for Swift & Objective C both. (using Swift 3.0 here)

    Adding & configuring font-awesome file & Editing Storyboard

    Just download font-awesome from here: fontawesome.io and add .ttf to your project

    Check the image below for more details...

    follow the sequence given in the image

    Now the coding part

    Swift 3.0

    let iconUniChar: UniChar = 0xf113  
    textLabel.text = String(format: "%C", iconUniChar) 
    

    Objective C

    _textLabel.text = [NSString stringWithFormat:@"%C", 0xf113];
    

    And, if you are still facing the trouble here's the

    entire source code

提交回复
热议问题