我遇到了iPhoneX后退按钮图像的问题。它没有在屏幕截图中看到的正确位置
我使用下面的代码设置背面图像
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UINavigationBar.appearance().backIndicatorImage = #imageLiteral(resourceName: "btn-back")
UINavigationBar.appearance().backIndicatorTransitionMaskImage = #imageLiteral(resourceName: "btn-back")
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -80.0), for: .default)
return true
}
}
任何人都可以解释为什么它处于不正确的位置以及如何解决这个问题?
答案 0 :(得分:0)
您可以使用topItem?.title
将导航标题设置为:
方法1:
self.navigationController?.navigationBar.topItem?.title = ""
<强>输出:强>
方法2:
let yourBackImage = UIImage(named: "back-Image")
self.navigationController?.navigationBar.tintColor = .red//.blue as you required
self.navigationController?.navigationBar.backIndicatorImage = yourBackImage
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = yourBackImage
self.navigationController?.navigationBar.topItem?.title = ""
<强>输出:强>
注意:作为Apple Human Interface GuideLine导航栏背面图片大小应为 -
75px×75px(3x)
样本图像3x(75 x 75) -