vaberer / font-awesome-swift Goto Github PK
View Code? Open in Web Editor NEWFont Awesome swift library for iOS.
License: MIT License
Font Awesome swift library for iOS.
License: MIT License
FontAwesome is causing a fatal error after updating to swift 3. The error is found in FAIcon.swift, line 130, font = fontAwesome! is nil. Code is cell.displayLabel.FAIcon = FAType.FAStar .
Pod is up to date at 1.4.8 on branch swift-3.
Please add in options to change the selected and unselected color for Tabbar Icons.
How can i init font icon with code? For example:
imageView.setFAIconWithCode(code: "fa-github")
Update to Font Awesome 4.4 please :-)
I am using this framework and trying to load in Icons in table view cells. SUPER buggy
The closest I have come to getting it to work properly is to create an image and use .setFAIconWithName:
usernameIconImage.setFAIconWithName(.FAMobile, textColor: UIColor.blackColor())
This only shows up half the time. I have considered putting it in a dispatch get main function but that causes the tableview to become choppy.
I also just get a questionmark icon if I try it with a label and try to put text in there with it:
self.usernameLabel.setFAText(prefixText: "", icon: .FAMobile, postfixText: " " + theDisplayedName, size: 18, iconSize: 19)
Anyone else experiencing this?
Looks like I will have to use another framework =(
In the UIButton and UILabel extensions, the setFAText function takes a parameter:
size: CGFloat?
I took this parameter to mean the size of the button/label text. There is an iconSize parameter which I took to mean the size of the icon. The function seems to use size and iconSize both as the size of the icon, leaving the text size unchanged.
If it is correct to assume the size parameter should be the size of the text (and icon if the iconSize parameter is null or not passed) then I think this is a bug. I commented out this line (numbers 113 and 192 in v 1.6.1):
//let textAttribute = [NSFontAttributeName:textFont!]
and put these three lines above the commented out line:
let textFontSize = size ?? textFont!.pointSize
let sizedTextFont = UIFont(name: textFont!.fontName, size: textFontSize)
let textAttribute = [NSFontAttributeName: sizedTextFont]
and it seemed to resize the text.
Found out that 1.4.3 has the ability to set the UIButton font to another font rather than system font, which is awesome.
However, also found out that cannot set the title color of the button anymore in 1.4.3 (defaulting to black), reverting back to 1.4.2 fixes it.
Will check whether I can fix this.
Hi Patrik,
was wondering if it's possible to use colors on the icons? Haven't worked that much with FA, but I'm not sure if it's at all possible... would be really nice, though.
Hi,
Is there any way to get different colors for the icon and the text? I have a button that has both icon and text, and I would like to use different colors for the two parts. However, button.setFATitleColor() sets the color fot both icon and text.
How can I set different colour for icon and text and set Center vertical between icon and prefixText in case different size
Does this work with page titles? i.e self.title ? If so, how?
I'm new to iOS programming. I've noticed that if I have a prefix containing the letters "g", "p", etc, the bottom part of the text is cut off when I use font awesome icons.
Is there a workaround to that? That's Swiftybutton by the way.
let icon = resultSearchController.active ? FAType(rawValue: helper.indexOf(filteredData[indexPath.row])!) : FAType(rawValue: indexPath.row)
c.lSmall.FAIcon = icon
c.lMedium.FAIcon = icon
c.lBig.FAIcon = icon
c.lBig.textColor = UIColor.redColor()
c.iIcon.setFAIconWithName(icon!, textColor: UIColor.blackColor())
c.lButton.setFAIcon(icon!, forState: .Normal)
c.lButton.setFATitleColor(UIColor.redColor())
Button color is not coming in red but lBig lable color is in red.
error: /path/to/home/Library/Developer/Xcode/DerivedData/App-xxx/Build/Products/Debug-iphonesimulator/Font-Awesome-Swift/Font-Awesome-Swift.bundle: No such file or directory
CocoaPods version: 1.0.0.beta.6
pod 'Font-Awesome-Swift', '~> 1.4.6'
platform :ios, '8.0'
any thoughts?
I use the Swift 2.3 branch and added Pod as:
pod 'Font-Awesome-Swift', '~> 1.4.8’
But that give me syntax errors in FASwift. Where am I gone wrong?
Great library - thanks! (new to Swift/iOS, though been using FA icons for many projects - glad to use them for latest one!)
Question is on setting the icon for tabs when you have more than 5.
Setting each was simple enough (the documentation states to use 'first', though we found we can do this for each one...)
`
tabBarController?.tabBar.items?[0].setFAIcon(icon:.FAUser)
tabBarController?.tabBar.items?[1].setFAIcon(icon:.FAUser)
tabBarController?.tabBar.items?[2].setFAIcon(icon:.FAUser)
tabBarController?.tabBar.items?[3].setFAIcon(icon:.FAUser)
tabBarController?.tabBar.items?[4].setFAIcon(icon:.FAUser)
`
Works great - IF you have only 5 tabs........
However, if you have a 6th tab, [4] no longer works....
When setting a 6th (or more) tab, iOS changes "#5" to "More" with a ... 'icon' and then the user can select which one they want (and also the user can arrange the tabs - not highly useful in our app, but a cool feature, I guess..)
So, this does NOT work..... (
tabBarController?.tabBar.items?[X].setFAIcon(icon:.FAUser)
(where 'X' is 5 or more)
Doing so get an error because the array is only 5 long.....
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 5 beyond bounds [0 .. 4]'
How to set the icons as FA Icons for these 'More' tabs?
Font awesome supports stacking icons as layers into one icon. http://fontawesome.io/examples/#stacked
Do you plan to introduce support for this?
----- example code i use right now to combine two icons:
Right now, for example to have a black Plus Icon within a yellow circle (musical.ly style) I would do:
let imageTopSize = CGSizeMake(44,44)
let imageBGSize = CGSizeMake(80,80)
let imageTopRect = CGRectMake((imageBGSize.width - imageTopSize.width)/2, (imageBGSize.height - imageTopSize.height)/2, imageTopSize.width, imageTopSize.height)
let imageBGRect = CGRectMake(0,0,imageBGSize.width, imageBGSize.height)
let imageTop = UIImage(icon: .FAPlus , size: imageBGSize, textColor: UIColor.blackColor())
let imageBG = UIImage(icon: .FACircle , size: imageTopSize, textColor:UIColor.yellowColor())
UIGraphicsBeginImageContextWithOptions(imageBGRect.size, false, 0.0)
imageBG.drawInRect(imageBGRect)
imageTop.drawInRect(imageTopRect)
let imageCombined = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let tabBarItemCreateImage = imageCombined!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)
self.init(CGImage: image.CGImage!, scale: image.scale, orientation: image.imageOrientation)
I’d like to use FontAwesome in my textfield but there’s no mention of UITextField in the README. Is it supported?
http://fontawesome.io/icon/user-circle-o/
http://fontawesome.io/icon/user-circle/
Can I make a pull request on this? I assume I have to update the FontAwesome font file and add missing enums. Perhaps more icons are missing.
Also it would be nice to have a page on how to add custom icons / font. I don't mind writing a wiki on it once I figure out how.
This library is awesome just like the font... but when I use it with a UIBarButtonItem the icon seems not to be aligned vertically with the title of the UINavigationBar and also very close from the boundary of the screen
Hey @Vaberer , any plans to push new podspec update soon?
Very handy pod, just wondering whether it's possible to have the icon a bit larger than the text?
Any plans on converting this to Swift 2? Want any help?
I have experienced that If I call setFAText for multiple times, the button font which has been defined in storyboard or code will missing. Is that a bug or something I did wrong? One thing I have figured out is that it looks somewhat related to button type (mine is custom).
My code as below:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(true)
setText()
}
func setText(){
locationLabel.setFAText(prefixText: "", icon: FAType.FALocationArrow, postfixText: " "+"Current Location".localized(), size: 15, forState: .Normal)
}
Thanks~
There is no option for UIButton as UIImageView to change image colour.
After importing in Carthage, I got an error saying "Module file 's minimum deployment target is ios 10.2".
Since I fixed the deployment target to 9.0 here, Shall I send you Pull requests?
Support for 4.7
// Works
button.setFAText(prefixText: "Some Text", icon: FAType.FAMap, size: iconSize, forState: .Normal)
button.setFATitleColor(.blueColor())
// Doesn't Work
button.setFATitleColor(.blueColor())
button.setFAText(prefixText: "Some Text", icon: FAType.FAMap, size: iconSize, forState: .Normal)
My use case makes it easier to set the text after the color, fortunately I have a workaround. Either way, this seems kind of buggy.
Using setFAIcon on a tabBarItem only sets the image, so the image goes missing when you select that tab item. Adding selectedImage to the extension will fix the problem:
`public extension UITabBarItem {
public func setFAIcon(icon: FAType) {
FontLoader.loadFontIfNeeded()
image = UIImage(icon: icon, size: CGSize(width: 30, height: 30))
selectedImage = UIImage(icon: icon, size: CGSize(width: 30, height: 30))
}
}`
I am not even sure this is possible, but is there any chance that this could be expanded to be used on a tab bar item? Thanks!
Does this support XCode 8.3?
I would like to have an option to append text after the icon (or prepend).
Will you consider working on this?
This is a useful library and I really thank you for making such good work for all developers.
For my use case, I've got a list of selections (only 1 can be selected at a time, like a segmented control), upon selecting an item, i set an FAType.FACheck for a button, additionally i want to disable or nullify all other buttons that might have an FACheck icon.
i'm envisioning an api like this:
button.unsetFAIcon()
or
button.setFAIcon(icon: nil, forState: .normal)
btw, love the work that you're doing.
Hello,
Please check this out. I got this error while running in Xcode: 8.1:
ld: framework not found Font_Awesome_Swift
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is my Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Management' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Management
target 'ManagementTests' do
inherit! :search_paths
# Pods for testing
end
target 'ManagementUITests' do
inherit! :search_paths
# Pods for testing
end
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
pod 'Font-Awesome-Swift', '~> 1.5.3'
end
Hi,
will there be Swift3.0 support?
Seems like this line does not suit:
let myString = NSMutableAttributedString(string: prefixText, attributes: textAttribute )
Error: "Cannot convert value of type [String: UIFont?] to expected argument type [String:AnyObject?]
Awesome library!
I am loading data from a backend system which gives me an iconName-String.
for example:
let iconName = "FABicycle"
I know this might be more a generic Swift question, but is it possible to use this variable (iconName) to get the FAType.FABicycle?
Thanks!
Any reason this doesn't support OS X apps?
How can I set the text at the bottom of button? Only support prefix and postfix?
Thanks!
This works fine:
let tabBarItem = self.tabBarController?.tabBar.items?.first
tabBarItem?.setFAIcon(icon: .FABell)
The tab icon FABell icon appears.
But the image and text color is blue even though the defaults to the setFAIcon method are black.
Passing a value for the selected selectedTextColor and other color properties do not seem to have any affect on the color.
How can you change the color? Are we doing something incorrectly?
Thanks
I would like to display a bunch of font awesome icons in a UIPickerView. Is this not supported?
Is there a Way to return the Icon as a string?
thanks
I would love to use this on UISlider support such as maximumValueImage
however it doesn't seem to work. Any possibility of future support for UISlider?
Line 356 in FAIcon.swift
if let image = image {
var imageOrientation = image.imageOrientation
if(orientation != UIImageOrientation.down){
imageOrientation = orientation
}
self.init(cgImage: image.cgImage!, scale: image.scale, orientation: orientation)
} else {
self.init()
}
in class FontLoader line 324:
fontURL = bundle.URLForResource(FAStruct.FontName, withExtension: "ttf", subdirectory: "Font-Awesome-Swift.bundle")!
just updated (pod install) and pod installed version 1.4.6
updated to version 1.4.8 and still have the issue. for some weird reason still pointing to line 324 but
there are no code there.. I cleaned up and build the project.. simple don't understand.
is a support carthage planned?
I have a UIButton with FAHeartO for state .Normal and FAHeart for state selected but when I change the state to selected at user taps the button the colors change.
If I have a normal button whit tintColor set to redColor in normal state but the selected estate shows the FAHeart in whiteColor and the background in redColor. I need the FAHeart in redColor with clearColor in the background.
Is this a bug?
Not sure if this is a bug or I am missing something in my code. When I set the imageView object of a UITableViewCell nothing happens.
cell.imageView?.setFAIconWithName(FAType.FAGithub, textColor: UIColor.blackColor())
Thanks for your assistance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.