FontAwesomeKit.Swift 1.0.2

FontAwesomeKit.Swift 1.0.2

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布日期最后发布2019年3月
SPM支持 SPM

qiuncheng 维护。



  • 作者
  • Qiuncheng

FontAwesomeKit.Swift

😀😘对于 iOS 开发者来说,使用 FontAwesome Icon 非常方便的 UI 库。😍
GitHub license

FontAwesome.otf 4.7.0

支持

Swift 4.2 & iOS 8.0+
FontAwesome 4.7.0
支持 Storyboard。

安装

CocoaPods

  1. 在你的 Podfile 中添加 pod 'FontAwesomeKit.Swift'
  2. 运行 pod install 或者 pod update
  3. 导入 FontAwesomeKit_Swift

手动

  1. 下载完整文件。
  2. 将 FontAwesomeKit 文件夹拖到您的项目中。

示例

在 Storyboard 中使用 FontAwesomeKit.Swift

  1. 将自定义类设置为 FontAwesomeButtonFontAwesomeLabel
  2. 在属性检查器 中为 FontAwesomeLabel 设置 Unicode 字符串,或为 FontAwesomeButton 设置 normalhighlightedselecteddisabled 的 Unicode 字符串,例如 f1070xf107
    // 所有 awesome Unicode --> http://fontawesome.io/cheatsheet/

FontAwesomeKit.Swift For Storyboard

使用 FontAwesomeKit.Swift 与字符串。

let str1 = String.fontAwesome(undefined: 0xf107)
let str2 = String.fontAwesome(awesomeType: .github)
let attrs = [NSFontAttributeName: UIFont(fontSize: 32)]
let attrStr1 = NSAttributedString(string: str1)
let attrStr2 = NSAttributedString(string: str2)

The attrStr1 will get icon. The attrStr2 will get icon.

使用 FontAwesomeKit.Swift 与 UILabel。

let label = UILabel()
label.text = .apple
label.font = UIFont(fontSize: 100)
/// text : FontAwesomeType.

使用 FontAwesomeKit.Swift 和 UIButton。

let button = UIButton(type: .custom)
button.setTitle(.gift, for: .normal)
/// type : The fontAwesome type, and you don’t need to ‘setImage’ or ‘setBackgroundImage’
/// state : The state that uses the specified title. The possible values are described in UIControlState.
button.titleLabel?.font = UIFont(fontSize: 50)

使用 FontAwesomeKit.Swift 和 UIImage。

let image1 = UIImage(awesomeType: .github)
/// fontSize : The fontSize you can give, default is 80.
/// tintColor : The UIImage filled color you get, default is UIColor.lightGray.
let image2 = UIImage(awesomeType: .github, size: 30.0, color: UIColor.black)

使用 FontAwesomeKit.Swift 和 UINavigationBarItem。

let rightItem = UIBarButtonItem(awesomeType: .github, style: .plain, target: nil, action: nil)
let leftItem = UIBarButtonItem(awesomeType: .github, size: 24, style: .plain, target: nil, action: nil)
/// fontSize : The font size, default is ‘24.0’
/// awesomeType : FontAwsomeType

授权

遵循MIT 许可协议

感谢

  1. FontAwesome Unicode 列表。 来自 fontawesome.io
  2. 最新版本 (版本 4.7.0) 的 FontAwesome.otf 套件