MKDropdownMenu
MKDropdownMenu copied to clipboard
How to change the background color of a component and title of another component depending on which row is selected?
I have a menu with two component - one for picking the color & another one for picking the music name. I need to change the background color of the component with the value that is selected from the color options (row). And again need to change the title of the component with the value the is selected from the string options (row).
I have these settings in the dropdown menu:
Now I need to change the color and music components' background color and title accordingly with the selected item from the row. Like this below image:
Hello @M-I-N,
Changing the component title should be simple, provide the necessary title in
- (nullable NSString *)dropdownMenu:(MKDropdownMenu *)dropdownMenu titleForComponent:(NSInteger)component
then in - (void)dropdownMenu:(MKDropdownMenu *)dropdownMenu didSelectRow:(NSInteger)row inComponent:(NSInteger)component
, store the selected title value somewhere and call [dropdownMenu reloadComponent:component]
.
For the background color, it's a bit more complicated, as providing different colors for every component is not supported out of the box. You can work around this by making the menu header color transparent and add your own colored backdrop view behind the menu.
Hope this helps!