New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is not working on interface builder. I see a question mark. Any help? #154
Comments
Probably the font was not loaded into memory before your storyboard was loaded. Do you have a sample project which reproduces this? |
let barButtonItem = UIBarButtonItem.init(title: "", style: .plain, target: target, action: action)
barButtonItem.setTitleTextAttributes([NSAttributedStringKey.font: UIFont.fontAwesome(ofSize: iconSize)], for: .normal)
barButtonItem.title = " \(String.fontAwesomeIcon(name: name)) "
barButtonItem.tintColor = color
return barButtonItem |
I have the same problem. I ended up just making them images :( I am using 1.2.0 |
@thii Is this a quick fix? |
I'll try to have a look at it sometime this weekend. |
Haven't tested it, but im pretty sure you have to set title text attributes for selected (and other) states too. |
yea.. maybe for a UIButton. But it doesnt work for a UILabel. |
I had the same issue, shows in storyboard and ? in app. I walked the FontFamily and noticed font wasn't loading as I only used it in storyboard, I added a call to |
Could someone confirm if in fact #170 provides a solution to this issue using: |
This has mostly been fixed for me, as mentioned by @phoney by applying attributes for multiple UIControlState enums, but the issue remains when a control is set to disabled (even though .disabled is used when setting the attributes). My guess is that the alpha of the BarButtonItem is causing the issue here, although when other enabled buttons are held down the alpha does not cause the icon to change to a [?] symbol. barButtonItem.setTitleTextAttributes([NSAttributedStringKey.font:
UIFont.fontAwesome(ofSize: iconSize)], for: .normal)
barButtonItem.setTitleTextAttributes([NSAttributedStringKey.font:
UIFont.fontAwesome(ofSize: iconSize)], for: [.selected, .highlighted, .disabled, .reserved]) |
@thii
Many thanks for your hard work! |
@james-ff |
@OlafAndreas |
@james-ff Can you setTitleTextAttributes for each of the states separately, without using the option set? That's how I've done it. When you tap on the barButtonItem, as shown in your video, the state of the barButtonItem changes to highlighted or selected, and apparently it doesn't know what to do in those cases. |
That worked! let titleTextAttributes = [NSAttributedStringKey.font: UIFont.fontAwesome(ofSize: iconSize)]
barButtonItem.setTitleTextAttributes(titleTextAttributes, for: .normal)
barButtonItem.setTitleTextAttributes(titleTextAttributes, for: .selected)
barButtonItem.setTitleTextAttributes(titleTextAttributes, for: .highlighted)
barButtonItem.setTitleTextAttributes(titleTextAttributes, for: .disabled) It seems that setting UIControlStates as an array of options has issues, which is a shame because it means less dry code. Would this be an issue with swift or this library? |
I think it's a UIKit issue and I think it's new in iOS 11. Never filed a bug though. Before that you could set the theme for .normal and it applied to all the states. I think it worked that way since the beginning. |
This also displays a question mark instead of an icon when I assign this to the text of a UILabel |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
closing this issue. |
I dragged a UILabel unto storyBoard.
Then i changed the font to font awesome.
Then i pasted the icon ->
It displays correctly on story board. But when i run the app, i am seeing a question mark.
Can you let me know the proper way to handle this on Interface builder/ Story board, with a UILabel?
The text was updated successfully, but these errors were encountered: