Open Isuru-Nanayakkara opened 10 years ago
Check this issue which has a commit for navigation customization
Thanks for that. I imported the MWPhotoBrowser.h and MWPhotoBrowser.m files from that fork but it seems to me that its a bit outdated. When I tried to run the project, it resulted in many errors. But I went through the files and identified the properties and methods that I have to change and I was able to customize the navigation and bars' tint and background colors.
Made some quick modifications to enable customization: https://github.com/mwaterfall/MWPhotoBrowser/pull/203
It would also be nice to have a way to set custom buttons for toolbar and navigation bar.
I second @HiveHicks :+1:
I've made an ungly (but working) hack.
This is what I've done:
1) Created a MYPhotoBrowser that extends MWPhotoBrowser 2) In the .m I've added the following code:
#import "MYPhotoBrowser.h"
@interface MWPhotoBrowser ()
- (void)setNavBarAppearance:(BOOL)animated;
@end
@implementation IDPhotoBrowser
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSArray *subviews = [self.view subviews];
for (int i = 0; i < subviews.count; i++)
{
UIView *subview = [subviews objectAtIndex:i];
if ([subview isKindOfClass:[UIToolbar class]])
{
((UIToolbar *) subview).barTintColor = [UIColor blueColor]; // the color wanted for the bottom toolbar
}
}
}
- (void)setNavBarAppearance:(BOOL)animated
{
[super setNavBarAppearance:animated];
self.navigationController.navigationBar.barTintColor = [UIColor greenColor]; // the color wanted for the nav bar
}
@end
Again, ugly, but working ;)
If you want to store your previous navigation bar color you should do next thing: 1) Find MWPhotoBrowser.m in pods 2) find - (void)setNavBarAppearance:(BOOL)animated 3) change navBar.barTintColor =nil; to navBar.barTintColor = _previousNavBarBarTintColor;
Extend @alexeybolv 's answer Also need to comment this : navBar.barStyle = UIBarStyleBlackTranslucent; And it works for me
@ivela can you please explain your answer? When I tried making subclass of MWPhotoBrowser none of the methods getting called of that subclass. Please explain process you have done for changing color of navigation bar. I have requirement of transparent navigation bar. If your code works for me rest I can manage. Please help in making this class.
Thanks Jankar
I need to change the color of the MWPhotoBrowser's navigation bar and tool bars. I don't see any properties to set values for these. Are they not implemented or am I missing them? If they don't exist, is there any workaround to achieve this?
Thanks