时间:2022-08-11 11:27:01 | 栏目:iOS代码 | 点击:次
APP中很多界面都是这样的、从有不透明到透明,透明到不透明
以下代码即可实现该功能
//设置导航栏透明 func setNavigationIsTranslucent(isTranslucent:Bool) { if isTranslucent == true { self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) self.navigationController?.navigationBar.shadowImage = UIImage() navigationController?.navigationBar.barStyle = .black }else { navigationController?.navigationBar.setBackgroundImage(UIImage(named: "nav_bg"), for: .default) navigationController?.navigationBar.shadowImage = UIImage() navigationController?.navigationBar.barStyle = .black } }
总结