设置导航栏透明

1,476 阅读1分钟

未透明时效果图:

透明后效果图:

只需四行代码即可:

[self.navigationController.navigationBar setBackgroundImage:[UIImage new]

forBarMetrics:UIBarMetricsDefault];

[self.navigationController.navigationBar setShadowImage:[UIImage new]];

[self.navigationController.navigationBar setBackgroundColor:[UIColor clearColor]];
}

35、36、37三行原图:

若碰到导航栏下方处有根细线无法祛除可尝试以下操作:

在xib文件中右侧, Table View---separator ---(更改为)None,即可。

以下为原图:

至此,完。