-
Notifications
You must be signed in to change notification settings - Fork 2
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
Breaks normal usage of setTitleColor #3
Comments
Hey @3lvis, this is primarily in response to https://github.com/hyperoslo/Form/issues/415. While this workaround would most likely work, I've got a good 20-30 buttons that break when this category is in use. Most of the buttons have images which darken on highlight, so the preferred fix would be something that doesn't require modifying core functionality. |
@uzegonemad Definitely! I agree, it should just work. |
Hi Elvis, me again. I am facing this issue, I changed your code, so the first time the button is clicked it takes automatically the normal and highlighted title color from the button. So there is no need to establish by code the title color. And buttons in xibs/storyboards with a custom highlight text colors will work ok with this. Have a look and tell me what you think. - (void)setHighlighted:(BOOL)highlighted
{
[super setHighlighted:highlighted];
if (self.highlightedTitleColor == nil){
self.highlightedTitleColor = [self titleColorForState:UIControlStateHighlighted];
}
if (self.titleColor == nil){
self.titleColor = [self titleColorForState:UIControlStateNormal];
}
if (self.highlightedTitleColor && self.titleColor) {
UIColor *titleColor = self.highlighted ? self.highlightedTitleColor : self.titleColor;
[self setTitleColor:titleColor forState:UIControlStateNormal];
[self setTitleColor:titleColor forState:UIControlStateHighlighted];
[self setTitleColor:titleColor forState:UIControlStateSelected];
}
if (self.highlightedBackgroundColor && self.originalColor) {
self.backgroundColor = self.highlighted ? self.highlightedBackgroundColor : self.originalColor;
}
}
|
@LightMan Wow, David. You came to save the day. This definitely fixes the issue. I'll push an update. Thanks a lot! |
all button will be gray after click, but i don't want that, this is still not well |
it affect all buttons - not just those implemented in Form. why do you use category |
@skarctop It's a category, and should only affect your buttons if you use any of the added attributes. |
Well, I had to change IMHO FORM should not use categories that override the default behaviour or any SDK's methods. Anyway, since I used this library I will gladly help to whatever changes are needed, but I think this will imply a decent change. @3lvis what do you think? |
@LightMan Makes sense :) Go for it. |
viewDidLoad
Sample project:
https://github.com/uzegonemad/hyperoslo-form-uibutton-issues
The text was updated successfully, but these errors were encountered: