Coder Social home page Coder Social logo

ranesr / swifticons Goto Github PK

View Code? Open in Web Editor NEW
800.0 14.0 107.0 6.47 MB

🎢Swift Library for Font Icons - ★ this library

Home Page: https://ranesr.github.io/SwiftIcons/

License: MIT License

Swift 99.63% Ruby 0.24% Objective-C 0.12%
fonts font-awesome fontawesome ionic map-icon material-icons linearicons open-iconic swift font-icons

swifticons's People

Contributors

ekurutepe avatar irshadpc avatar madhavajay avatar ranesr avatar sepbehroozi avatar ynnadrules 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

swifticons's Issues

Using setIcon with no icon (at the moment attempt to set icon to nil results in crash)

It might sound counterintuitive, but I wanted to use setIcon() to set a normal button title, with no icon at all.

Why I was trying to do this? I have a button, which changes its state - one of the states has icon and another doesn't have it. I simply wanted to have cleaner code like this:

    enum ButtonState {
        case gift, cancel
    }
    
    private func updateButton(state: ButtonState) {
        self.buyGiftButton.setIcon(prefixText: "", prefixTextFont: myFont,
            icon: state == .gift ? .fontAwesome(.gift) : nil,
            postfixText: state == .gift ? " Buy as a gift" : "Cancel", postfixTextFont: myFont, postfixTextColor: .white,
            backgroundColor: myColor, forState: .normal, iconSize: 20)
    }

But it looks like the icon is force-unwrapped in there and this is not possible. Instead I had to make if-else and do .setAttributedTitle for that button.

It would be good if icon was really handled as an optional in setIcon (feature request).

Different constants not resizing for iPad

I am assigning a button icon to different screen sizes. It only works on the iPhone settings and not the iPad.

storyboard constant settings.

Screen Shot 2019-05-06 at 10 43 47 AM

iPad results - the icon does not resize. It also does not center to the new size. The text does center.

Screen Shot 2019-05-06 at 10 42 59 AM

iphone settings are fine.

Screen Shot 2019-05-06 at 10 39 26 AM

Using Swift 4.2 and Xcode 10.2.1

Building SwiftIcons on Xcode 10.2.1 takes forever

I've update the Xcode into 10.2.1 after I've cleaned the project and build again. Xcode struck on building SwiftIcons like there's no ending to it. There is no error appears so far.

Xcode Version 10.2.1 (10E1001)
SwiftIcons version 2.3.2
Swift Language Version 4.2

Any planned support for adding custom fonts?

I tend to have some vector icons I load up in custom font file. I wish there was support or I end up forking it and manually having to add it in. It would be nice if it was more dynamic as to be able to load font files of your choosing without including all of them.

ionicons rewind misspelt

In ionicons.com there are ion-ios-rewind and ion-ios-rewind-outline icons yet in SwifIcons they are spelled as iosReward and iosRewardOutline accordingly. They should be renamed.

Icons showing as "?"

I have noticed the icons sometimes are rendered as question marks. This happens when you return to a view in the navigation stack or when a viewcontroller is presented in a modal.

Im using version 2.0.1 which should have a fix to a similar issue.
I have tested on an iPhone 8 plus with the latest iOS and on the Simulators and the issue is the same.

UIButton, UISegmentControl and UILabels all present the same issue.
screen shot 2018-04-05 at 23 19 38
image

Why is text centered when setting icon to UILabel?

Why does the function UILabel.setIcon(...) change the alignment of the text on the label to .center? The documentation on these functions do not specify that the alignment is changed. I found this to be unexpected behavior and I don't want to the alignment on my label to be changed when using this function.

Found in SwiftIcons.swift in the following functions:

setIcon(prefixText: String, prefixTextColor: UIColor = .black, icon: FontType?, iconColor: UIColor = .black, postfixText: String, postfixTextColor: UIColor = .black, size: CGFloat?, iconSize: CGFloat? = nil) {
    // ...
    textAlignment = .center
}

setIcon(prefixText: String, prefixTextFont: UIFont, prefixTextColor: UIColor = .black, icon: FontType?, iconColor: UIColor = .black, postfixText: String, postfixTextFont: UIFont, postfixTextColor: UIColor = .black, iconSize: CGFloat? = nil) {
    // ...
    textAlignment = .center
}

Is there a reason why the alignment is changed? If not I would suggest removing the line.

Is there a way can use String to set Icon?

normally use enum to tell func what icon u want ?
cell.imgvIcon.setIcon(icon: .fontAwesome(.addressBook))

but if the icon type is from server, can i use string to set icon ?
cell.imgvIcon.setIcon(iconString: "fontAwesome.addressBook")

i found .text can get name of this icon.
Can i use this name as parameter?

UIBarButtonItem is not aligned

Hi, I'm using SwiftIcons library (installed though Pod).

I'm trying to create UIBarButtonItem with specific icon.
I set it like this:
menuButton.setIcon(icon: .ionicons(.navicon), iconSize: 35, color: systemColor)
where systemColor == UIView().tintColor
But with this setup, my UIBar looks like this:
image
As, you can see it is not aligned vertically (I tried using SetTitlePositionAdjustment, but I can adjust only horizontal position).

I kinda fixed the position by using:
menuButton.setIcon(prefixText: "", icon: .ionicons(.navicon), iconColor: systemColor, postfixText: "", cgRect: CGRect(x: 30, y: 30, width: 30, height: 30), size: 35, iconSize: 36)
image

But, then button is not tappable...

Can anyone help me here?

CocoaPods could not find compatible versions for pod "SwiftIcons": on Xcode 10

Try to install via cocoapods but I have faced compatible issues. I have using Xcode 10.

[!] CocoaPods could not find compatible versions for pod "SwiftIcons":
In Podfile:
SwiftIcons (~> 2.2.0)

None of your spec sources contain a spec satisfying the dependency: SwiftIcons (~> 2.2.0).

You have either:

  • out-of-date source repos which you can update with pod repo update or with pod install --repo-update.
  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

Rounded Corner

Is there a way of making an icon have a corner radius when a background colour is present?

How to map the icon name to the library's enum?

For example the IcoFont 5-start-hotel is referenced by .icofont(.fiveStarHotel), is there any direct mapping?

Or is there any way to reference the icon using unicode? such as ef05 to get 5-star-hotel.

screen shot 2017-06-30 at 3 47 36 pm

Update Podspec

The last merged PR (#57) did not update the podspec file. Please, do so.

Does not work with swift 3

many of the methods has been renamed

  1. NSParagraphStyleAttributeName' has been renamed to 'NSAttributedStringKey.paragraphStyle'
    Well there are total 33 methods which has been renamed and hence shows issues for swift 3

UIBarButtonItem shows questionmark placeholder while the button action gets performed in iOS 11

I have multiple UIBarButtonItems like this:
let plusButton = UIBarButtonItem(title: "Plus", style: .plain, target: self, action: #selector(showMore))
plusButton.setIcon(icon: .ionicons(.iosPlusOutline), iconSize: 25.0, color: Colors.drakGreen)
Till iOS 10 everthing worked fine. But under iOS 11 I get a questionmark placeholder when I press one of the buttons. This placeholder stays there until the action the button triggers is completed:
2017-09-27 13 12 04

Swift 4 support?

Can we get swift 4 supp? Now there are a lot of compile errors

Terminal Warnings for UIButton

On iOS9 and up, these terminal warnings are shown:

[Assert] button text attributes only respected for UIControlStateNormal, UIControlStateHighlighted, UIControlStateDisabled and UIControlStateFocused. state = 4 is interpreted as UIControlStateHighlighted.

UIColor extension ambiguous when using Hue

Popular UIColor library Hue uses the UIColor(hex:) constructor in an extension, leading to a conflict with the convenience init in the UIColor extension.

public extension UIColor { convenience init(hex: String) {

Raising the error:

Ambiguous use of init(hex:)
Please remove or consider making Hue a dependency or using a non-conflicting category convenience method?

Why icon position on top for UILabel with postfix text.?

I added a label with icon and postfix text.
The icon is set to top position.
Please find my code

label.setIcon(prefixText: "", prefixTextColor: .clear, icon: .appsFont(.keyboard_arrow_down), iconColor:.blue, postfixText: text, postfixTextColor: .blue, size: 18, iconSize: 18)

screen shot 2018-08-31 at 10 47 59 am

I need that arrow center alignment to text.

Please suggest how to overcome this issue.

Thanks in advance.

How does this project work?

Hello,

Are all of these icons stored in the library? If so, how is the library so small?

Do only used icons from the library ship with the app bundle?

Thanks,
-Sami

Bold font not staying

I have a UILabel which sometimes has an icon and sometimes not. By default the label is set with a bold font in the Storyboard and at the launch it does not contains any icon (the text is simply set with label.text).

If I apply the icon and the text with .setIcon(), the first time the bold attribute will stay but if I run .setIcon() a second time to update the text content, the font will be overwritten with the standard one, being not bold.

The only workaround I found is to store in a variable during viewDidLoad() the original bold font and before each execution of .setIcon() I re-set the original font with label.font = initialLabelFont.

UIButton iconColor is ignored when title is present

I am using the following code alter the color of the text as well as the icon:

trendingTabButton.setIcon(icon: .emoji(.fire), iconColor: .red, title: "Title", titleColor: .yellow, backgroundColor: UIColor.clear, borderSize: 0, borderColor: UIColor.clear, forState: .normal)

But when I run this the title is red yet the icon is the default blue still

Move icons to different pods

While compiling my project copying icons take too much time especially Dripicons.ttf which I don't use. I only use FontAwesomeSolid.ttf. Is it possible to move icons to different pods so we can opt out like:

pod 'SwiftIcons', '~> 2.3.2'
pod 'SwiftIcons/FontAwesomeSolid'

setting barbuttonItems cuts off icon

When I set a navigation bar like below, the icon gets cut off.

let settingsBarButton = UIBarButtonItem()
settingsBarButton.setIcon(icon: .emoji(.gear), iconSize: 30)
navigationItem.rightBarButtonItems = [settingsBarButton]

image

Not sure what's wrong since the example in your readme also uses size 30.

edit:
setting it via

settingsBarButton.image = UIImage(icon: .emoji(.gear), size: CGSize(width: 30, height: 30))

works fine

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.