As below, I set NavigationBar Height without using NavigationController.
(use navigation bar as a standalone object)
UINavigationBar* navbar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
UINavigationItem* navItem = [[UINavigationItem alloc] initWithTitle:@"title"];
UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onTapCancel:)];
navItem.leftBarButtonItem = cancelBtn;
UIBarButtonItem* doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(onTapDone:)];
navItem.rightBarButtonItem = doneBtn;
[navbar setItems:@[navItem]];
[self.view addSubview:navbar];
But it doesn’t work on iOS11 beta.
Actually, the NavBar Height looks always default Height = 44.
It works before iOS10.
I tried beta7, but nothing changes.
Is there any way to set NavigationBar Height?
addition
I tried to apply Autolayout Constraint like following code.
In this case, "leadingAnchor", "topAnchor", "widthAncohr" works as I expected.
but I couldn't control "heightAnchor".
This is tried on iOS11 GM version.
UINavigationBar* navbar = [[UINavigationBar alloc] init];
navbar.translatesAutoresizingMaskIntoConstraints = false;
UINavigationItem* navItem = [[UINavigationItem alloc] initWithTitle:@"title"];
UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onTapCancel:)];
navItem.leftBarButtonItem = cancelBtn;
UIBarButtonItem* doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(onTapDone:)];
navItem.rightBarButtonItem = doneBtn;
[navbar setItems:@[navItem]];
[self.view addSubview:navbar];
[NSLayoutConstraint activateConstraints:@[[[navbar leadingAnchor] constraintEqualToAnchor:self.view.leadingAnchor constant:0]]];
[NSLayoutConstraint activateConstraints:@[[[navbar topAnchor] constraintEqualToAnchor:self.view.topAnchor constant:50]]];
[NSLayoutConstraint activateConstraints:@[[[navbar heightAnchor] constraintEqualToConstant:100.0]]];
[NSLayoutConstraint activateConstraints:@[[[navbar widthAnchor] constraintEqualToAnchor:self.view.widthAnchor]]];