我正在使用导航栏的背景图像 . 它在呈现视图控制器时崩溃我的应用程序 . 我也有所有视图控制器视图的背景图像 . 我正在使用像这样的实现
func setNavigationAppearance(tintColor : UIColor, barTintColor : UIColor?) {
let navigationBarAppearace = appDelegateObj.navigationController!.navigationBar
navigationBarAppearace.tintColor = tintColor
navigationBarAppearace.barTintColor = barTintColor
navigationBarAppearace.translucent = false
//navigationBarAppearace.
//Settign the Custome Font and TextColor
if let font = UIFont(name: FontCustom.Regular, size: 17) {
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: font ,NSForegroundColorAttributeName : tintColor]
}
}
我用这个图像调用这个方法让navigationColor:UIColor = UIColor(patternImage:UIImage(named:AppImagesName.PatternRed)!)
我收到这些崩溃日志 .
由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'在这种情况下仅支持RGBA或白色空格
我用Google搜索,所有人都说删除背景图片或这是iOS错误 .
所以请告诉我可能的解决方案 .
1 回答
要将背景图像设置为NavigationBar,请使用以下代码:
截图示例:
要测试样本,请检查我的GitHub链接:
https://github.com/k-sathireddy/NavigationBarBackgroundImageSample