Elegantly use ZMDI (Material Design Iconic Font) and FontAwesome icons in Swift for iOS.
Use is easy as 🍰; type the icon code you want to use followed by .zmdi
or .fa
and then .icon
or .image
. This will return an optional String and UIImage, respectively. If you're using .icon
, remember to set the font for the label / button / whatever beforehand.
label.font = .zmdi(size: 20)
label.text = "zmdi-remote-control".zmdi.icon
label.font = .fa(size: 20)
label.text = "fa-user".fa.icon
imageView.image = "zmdi-remote-control".zmdi.image(color: .white, size: imageView.frame.size)
imageView.image = "fa-user".fa.image(color: .white, size: imageView.frame.size)
Prefacing the icon code with fa
or zmdi
is unnecessary; you can drop it off if you want.
label.text = "address-book".fa.icon
label.text = "satellite".zmdi.icon
Check out this Example Code for more usage examples.
To run the example project, clone the repo, and run pod install
from the Example directory first.
SwiftFontIcons is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SwiftFontIcons'
If you get some sort of spec error, try pod repo update
or:
pod 'SwiftFontIcons', :git => 'https://github.com/daaavid/SwiftFontIcons.git', :branch => 'master'
daaavid, [email protected]
SwiftFontIcons is available under the MIT license. See the LICENSE file for more info.