MWPhotoBrowser icon indicating copy to clipboard operation
MWPhotoBrowser copied to clipboard

Customize the photo browser's navigation and tool bars

Open Isuru-Nanayakkara opened this issue 11 years ago • 9 comments

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

Isuru-Nanayakkara avatar Jan 12 '14 11:01 Isuru-Nanayakkara

Check this issue which has a commit for navigation customization

https://github.com/mwaterfall/MWPhotoBrowser/issues/184

macpraveen avatar Jan 12 '14 15:01 macpraveen

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.

Isuru-Nanayakkara avatar Jan 12 '14 18:01 Isuru-Nanayakkara

Made some quick modifications to enable customization: https://github.com/mwaterfall/MWPhotoBrowser/pull/203

juzzin avatar Feb 15 '14 14:02 juzzin

It would also be nice to have a way to set custom buttons for toolbar and navigation bar.

HiveHicks avatar Mar 19 '14 08:03 HiveHicks

I second @HiveHicks :+1:

Isuru-Nanayakkara avatar Mar 19 '14 08:03 Isuru-Nanayakkara

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

ivela avatar Apr 06 '15 16:04 ivela

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;

alexeybolv avatar Jul 22 '16 10:07 alexeybolv

Extend @alexeybolv 's answer Also need to comment this : navBar.barStyle = UIBarStyleBlackTranslucent; And it works for me

Winston-liu-ray avatar Jan 09 '17 07:01 Winston-liu-ray

@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

jankarrajpara avatar Sep 25 '18 07:09 jankarrajpara