FontAwesomeKit.Swift
ios开发人员最好选择使用UI的Fontawesome图标。
支持
Swift 4.2&iOS 8.0+
Fontawesome 4.7.0
情节板支持。
安装
可可录
- 将
pod \' FontAwesomeKit.Swift \'添加到您的podfile中。 - 运行
pod install或pod update。 -
import FontAwesomeKit_Swift
手动
- 下载完整文件。
- 将fontawesomekit文件夹拖到您的项目中。
例子
在情节板中使用FontAwesomeKit.Swift 。
- 将自定义类设置为
FontAwesomeButton或FontAwesomeLabel - 将Unicode字符串设置为
FontAwesomeLabel属性检查器或设置normal,highlighted,selected,disabledUnicode字符串,例如FontAwesomeButton,例如f107或0xf107
//所有很棒的unicode-> http://fo**n*tawesome.io/cheatsheet/
使用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)
attrstr1将获得图标。 attrstr2将获得图标。
使用uilabel的FontAwesomeKit.Swift 。
let label = UILabel()
label.text = .apple
label.font = UIFont(fontSize: 100)
/// text : FontAwesomeType.
使用uibutton使用FontAwesomeKit.Swift 。
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)
使用uiimage的FontAwesomeKit.Swift 。
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
执照
根据麻省理工学院许可证
谢谢
- Fontawesome Unicode列表。来自fontawesome.io
- 最后(版本4.7.0)fontawesome.otf捆绑
