mwaterfall / MWPhotoBrowser

A simple iOS photo and video browser with grid view, captions and selections.
MIT License
8.75k stars 2.72k forks source link

Customize the photo browser's navigation and tool bars #198

Open Isuru-Nanayakkara opened 10 years ago

Isuru-Nanayakkara commented 10 years ago

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

macpraveen commented 10 years ago

Check this issue which has a commit for navigation customization

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

Isuru-Nanayakkara commented 10 years ago

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.

juzzin commented 10 years ago

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

HiveHicks commented 10 years ago

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

Isuru-Nanayakkara commented 10 years ago

I second @HiveHicks :+1:

ivela commented 9 years ago

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

alexeybolv commented 8 years ago

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;

Winston-liu-ray commented 7 years ago

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

jankarrajpara commented 6 years ago

@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