Skip to content

Instantly share code, notes, and snippets.

@bimawa
Last active August 29, 2015 14:00
Show Gist options
  • Save bimawa/cea601fcafef569bb38b to your computer and use it in GitHub Desktop.
Save bimawa/cea601fcafef569bb38b to your computer and use it in GitHub Desktop.
MHViewController.m with customization navigationController
- (void)loadView
{
[super view];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self setEdgesForExtendedLayout:UIRectEdgeBottom];
[self p_configureNavigationBar];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
#pragma mark - Private
- (void)p_configureNavigationBar
{
// Left Button
MHNavigationButton *leftViewButton = [MHNavigationButton mhNavigationButtonWithType:MHNavigationButtonTypeBack];
[leftViewButton addTarget:self action:@selector(a_pressedNavigationButtonLeft:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barButtonItemLeft = [[UIBarButtonItem alloc] initWithCustomView:leftViewButton];
self.navigationItem.leftBarButtonItem = barButtonItemLeft;
// Right Button
MHNavigationButton *rightViewButton = [MHNavigationButton mhNavigationButtonWithType:MHNavigationButtonTypeCamera];
[rightViewButton addTarget:self action:@selector(a_pressedNavigationButtonRight:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barButtonItemRight= [[UIBarButtonItem alloc] initWithCustomView:rightViewButton];
self.navigationItem.rightBarButtonItem = barButtonItemRight;
MHNavigationTitleLabel *navigationBarTitleLabel = [[MHNavigationTitleLabel alloc] initWithFrame:CGRectZero withTitle:self.title];
[self.navigationItem setTitleView:navigationBarTitleLabel];
[[self.navigationController navigationBar] setBarTintColor:[UIColor colorWithRed:0.204 green:0.596 blue:0.859 alpha:1.000]];
UILabel *titleView = [UILabel new];
[titleView setTextColor:[UIColor whiteColor]];
[titleView setText:@"Фотография"];
[titleView setFont:[UIFont fontWithName:@".HelveticaNeueInterface-Bold" size:16]];
[titleView sizeToFit];
self.navigationItem.titleView = titleView;
}
#pragma mark - Actions
- (void)a_pressedNavigationButtonLeft:(MHNavigationButton *)navigationButton
{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)a_pressedNavigationButtonRight:(MHNavigationButton *)a_pressedNavigationButtonRight
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment