Closed RathaKrishna closed 7 years ago
Because UITabBarItem
can not dynamically modify the image, so you need to create a new item when updating the theme.
In the following steps:
Register the theme update in the controller that sets the tabBarItem
, or in the custom UITabBarController
subclass.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTabBarItem) name:@"ThemeUpdateNotification" object:nil];
How to set plist, can be found in the document and PlistDemo
. And then set the image to be updated, and then set it to tabBarItem
is complete.
- (void)updateTabBarItem {
UIImage *image = [ThemeManager imageForKeyPath:@"some_image_keypath"];
UIImage *selectedImage = [ThemeManager imageForKeyPath:@"some_selected_image_keypath"];
// If it is in the subclass of UITabBarController, update the corresponding controller one by one.
self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Some Title" image:image selectedImage:selectedImage];
}
Please tell me if it is resolved.
Yes it's working like charm !!! thank you.
Is there is any way to use plist demo on OC project to change UITabbarItem's image and selectedImage dynamically based on theme ?