对于您的第二个问题,您可以使用以下代码使导航栏透明:
public func makeNavigationBarWithoutBorder(color: UIColor = UIColor.clear) {
self.navigationBar.isTranslucent = true
self.navigationBar.backgroundColor = UIColor.clear
let image = UIImage.init(color: color)
self.navigationBar.setBackgroundImage(image, for: .default)
self.navigationBar.shadowImage = image
self.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
}
现在添加左右按钮,如下所示。
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: Asset.greyCross.image, style: .plain, target: nil, action: nil)
self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: Asset.greyCross.image, style: .plain, target: nil, action: nil)
希望这将为您提供第二个解决方案。