I have a project like this:
But I'm trying to figure out how to add a banner below the navigation bar across the navigation bar in a way where can I hide it if is need it. Any of you knows how can I do this?
I have a project like this:
But I'm trying to figure out how to add a banner below the navigation bar across the navigation bar in a way where can I hide it if is need it. Any of you knows how can I do this?
plz use TSMessages.
This library provides an easy to use class to show little notification views on the top of the screen
https://github.com/KrauseFx/TSMessages
In the main view controller implement the protocol UINavigationControllerDelegate
and in the selector navigationController:didShowViewController:animated:
you can manipulate the view controller presented by the navigation controller. e.g:
@interface ViewController () <UINavigationControllerDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.delegate = self;
}
-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
UIView *banner = [[UIView alloc] initWithFrame:CGRectMake(0, navigationController.navigationBar.frame.size.height + 10,
viewController.view.bounds.size.width,30)];
banner.backgroundColor = [UIColor blueColor];
[viewController.view addSubview:banner];
}
@end
In this example ViewController
should be the first view controller presented for the UINavigationController
.
I uploaded an example on github
Hope it helps
for objective-c, use RMessage
for swift, use SwiftMessages. Preview