maxkonovalov/MKDropdownMenu

Menu does not respect UIViewTintAdjustmentModeDimmed

ahndee opened this issue · 6 comments

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)?

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.

Thanks - works great!

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.

@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.

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.

Added the accessibility fix - thanks @ahndee!