Please check here . The link has different ways to solve the problem. However following code helped me.
for subview in (self.navigationController?.navigationBar.subviews)! {
if NSStringFromClass(subview.classForCoder).contains("BarBackground") {
var subViewFrame: CGRect = subview.frame
// subViewFrame.origin.y = -20;
subViewFrame.size.height = 100
subview.frame = subViewFrame
}
}
You can able to set it as follows
-(void)layoutSubviews{
[super layoutSubviews];
CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
if (rectStatus.size.height==44.f) {
}else{
if (@available(iOS 11.0, *)) {
for ( UIView*aView in self.subviews) {
if ([NSStringFromClass(aView.classForCoder) isEqualToString:@"_UINavigationBarContentView"]) {
aView.frame = CGRectMake( 0,20,aView.frame.size.width,44);
}
else if ([NSStringFromClass(aView.classForCoder) isEqualToString:@"_UIBarBackground"]) {
aView.frame = CGRectMake(0,0,aView.frame.size.width, 64);
}
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.