let backImage:UIImage = (UIImage.init(named: "Back-btn")?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 30, 0, 0)))!
UIBarButtonItem.appearance().setBackButtonBackgroundImage(backImage, for: .normal, barMetrics: .default)
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-60, -60),for:.default)
我想在应用开始时在appdelegate.swift
中定义后退按钮的外观。而且我也不需要后退按钮的标题。
我想在后退按钮中删除这些痕迹。
答案 0 :(得分:2)
替换
let backImage:UIImage = (UIImage.init(named: "Back-btn")?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 30, 0, 0)))!
带
let backImage: UIImage = UIImage(named: "Back-btn")!.stretchableImage(withLeftCapWidth: widthOfTheBackButtonImage, topCapHeight: 0)
其中widthOfTheBackButtonImage
是图像的宽度。您还必须确保图像右侧至少有1个透明点。