Skip to content
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

ToolbarItems Font For Other States #24

Closed
Mahan3340 opened this issue Oct 14, 2017 · 6 comments
Closed

ToolbarItems Font For Other States #24

Mahan3340 opened this issue Oct 14, 2017 · 6 comments

Comments

@Mahan3340
Copy link

Hi , setting ToolbarItems Fonts is currently just set for the .normal state of the buttons and when you click it or longPress (hold) on it the font is changed to default for a moment or for the time you are holding it

@kmcgill88
Copy link
Owner

Hi @Mahan3340, thanks for the post. Do you have any suggestions to improve this? .normal is currently hardcoded.

@Mahan3340
Copy link
Author

Hi , sorry I forgot to mention that I fixed it by adding .selected state like below
barButtonItem.setTitleTextAttributes([.font: toolbarItemsFont!], for:UIControlState.selected)

@kmcgill88
Copy link
Owner

I assume you did that in your own fork? This seems like a nice option to add in to McPicker but I can’t think of a way to do it using the ‘didSet’ approach. I think it would have to be changed to a ‘func’. What do you think?

@Mahan3340
Copy link
Author

Mahan3340 commented Oct 17, 2017

yea I unlocked the files and made changes to them , and I've also added this to didSet

 public var toolbarItemsFont: UIFont? {
        didSet {
            applyToolbarButtonItemsSettings { (barButtonItem) in
                barButtonItem.setTitleTextAttributes([.font: toolbarItemsFont!], for: .normal)
                 barButtonItem.setTitleTextAttributes([.font: toolbarItemsFont!], for:UIControlState.selected)
               }
        }
    }

I guess its fine to add it this way :D
or you can also add a func for different states maybe

@kmcgill88
Copy link
Owner

Actually, looking at the code you posted I feel like setting the same font for .normal and .selected should be the default behavior. I'd sure think 99% of the time you'd want these the same. I will get it added the next time I work on this.

@Mahan3340
Copy link
Author

yea I guess no one want different fonts for these states so can be added right there 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants