maxkonovalov / MKDropdownMenu

🔻 Dropdown Menu for iOS with many customizable parameters to suit any needs
MIT License
527 stars 83 forks source link

Menu does not respect UIViewTintAdjustmentModeDimmed #13

Closed ahndee closed 7 years ago

ahndee commented 7 years ago

I currently don't see a way to change the menu's tintColor when it should be dimmed (UIViewTintAdjustmentModeDimmed, e.g., when an UIAlertView is presented).

Due to this all my app's UI currently properly dims but the dropdown menu doesn't, which makes things look out of place (when collapsed, the title doesn't dim but the disclosureIndicator does, making even the menu itself inconsistent).

Would it be possible to properly support tintColorDidChange within the class itself or is there a way around to do this now (e.g., using tintColorDidChange in the containing class and the refresh the menu)?

maxkonovalov commented 7 years ago

Hello @ahndee, The component titles originally were not intended to be tinted automatically, whereas the disclosure indicators used the view's tint color. I think I'll add an option to enable this behavior somehow. For now, you can easily work around this issue by using a custom view with a system button for the component:

- (UIView *)dropdownMenu:(MKDropdownMenu *)dropdownMenu viewForComponent:(NSInteger)component {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    [button setTitle:@"Component Title" forState:UIControlStateNormal];
    button.userInteractionEnabled = NO;
    return button;
}

I tested this, and it worked as expected, dimming the whole menu when an alert controller is presented.

ahndee commented 7 years ago

Thanks - works great!

ahndee commented 7 years ago

One issue with this however, the component title loses its VoiceOver label that way. I was able to fix this by adding

button.accessibilityLabel = customView.accessibilityLabel;

after line 1072 in the

- (void)updateButton:(MKDropdownMenuComponentButton *)button forComponent:(NSInteger)component

method implementation.

maxkonovalov commented 7 years ago

@ahndee I didn't support the accessibility in the control initially – if you have some fixes for this, would be great if you provide a pull request.

ahndee commented 7 years ago

Since the control uses UIButton which supports accessibility, everything works when not overriding things. When overriding the title the one line needs to be added in order for the UIView to inherit things.

maxkonovalov commented 7 years ago

Added the accessibility fix - thanks @ahndee!