GithubHelp home page GithubHelp logo

vaberer / font-awesome-swift Goto Github PK

View Code? Open in Web Editor NEW
744.0 28.0 127.0 839 KB

Font Awesome swift library for iOS.

License: MIT License

Swift 98.68% Ruby 0.76% Objective-C 0.56%
swift font-awesome cocoapods swift-3 swift-library font-icons font ios icons xcode

font-awesome-swift's People

Contributors

adam-casey avatar artshin avatar feelingplace avatar george-gw avatar graemer957 avatar jaimeagudo avatar jkmassel avatar marekmatula avatar michaelsabo avatar othyn avatar ranesr avatar sbero avatar scottphc avatar snagra avatar tchukuchuk avatar uiapplicationmain avatar vaberer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

font-awesome-swift's Issues

UITabBar color

Please add in options to change the selected and unselected color for Tabbar Icons.

icon shows up half the time

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 =(

UIButton & UILabel setFAText size parameter changes icon size only, not font size

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.

UIButton Title Color not working in 1.4.3

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.

Color on FAIcons

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.

Different colors for icon and text

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.

Bottom part of text cut off

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.

Imgur

Is there a workaround to that? That's Swiftybutton by the way.

Not able to set the button color using setFATitleColor?

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.

Can't find bundle / No such file or directory [cocoapods beta7 issue]

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?

FontAwesome for Swift 2.3?

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?

Setting FA Icon on 5th UITabbarItem causes NSException

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?

Stacked Icons Support

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)

Imageview's setFAIconWithName has bug

fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)

    self.init(CGImage: image.CGImage!, scale: image.scale, orientation: image.imageOrientation)

setFAIcon on UITextField

I’d like to use FontAwesome in my textfield but there’s no mention of UITextField in the README. Is it supported?

UIBarButtonItem position

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

Swift 2

Any plans on converting this to Swift 2? Want any help?

text font missing when using "setFAText" for multiple times

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~

Color doesn't apply to text unless it's set after the text is set.

// 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.

UITabBarItem selectedImage

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))
    }
}`

Appending string text after icon

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.

Remove/Unset Icon

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.

Framework not found Font_Awesome_Swift

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

Swift 3.0 Support

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?]

Setting icons with variables as iconname

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!

UITabBarItem color options not working

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

No support for UIPickerView?

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

[Feature Request] UISlider support?

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?

fatal error: unexpectedly found nil while unwrapping an Optional value

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.

Problem when tap a button a change state to selected

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?

Attempting to set imageView of a UITableViewCell

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.