maxkonovalov / MKDropdownMenu

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

How to change the background color of a component and title of another component depending on which row is selected? #34

Open M-I-N opened 7 years ago

M-I-N commented 7 years ago

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: untitled11 untitled12

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: untitled13

maxkonovalov commented 7 years ago

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!