更新整个项目的导航栏后退按钮图像 [英] Update navigation bar back button image for the whole project

查看:18
本文介绍了更新整个项目的导航栏后退按钮图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更新整个项目的导航栏后退按钮图像,我从下面的代码中实现了这一点,但问题是后退按钮显示了我不想要的两条相邻行.请指导我是否有任何代码可以删除这些行.

I need to update the navigation bar back button image for the whole project some sort I achieved this from the code below, But the problem is back button is showing two adjacent lines which are un wanted for me. Please guide me is there any code to remove those lines.

let image = UIImage(named:"backButton")
        let backImage = image?.imageWithRenderingMode(.AlwaysOriginal).resizableImageWithCapInsets(UIEdgeInsetsMake(0, 13, 0, 6))

        UIBarButtonItem.appearance().setBackButtonBackgroundImage(backImage, forState: .Normal, barMetrics: .Default)
        UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-400, 0), forBarMetrics: .Default)

推荐答案

这两行是扭曲的 backButton 图像的一部分,由于不正确的大写插图而出现.设置大写以覆盖整个图像会有所帮助.例如:

These 2 lines are parts of the distorted backButton image that appear because of the incorrect cap insets. Setting caps to cover the whole image would help. e.g.:

if let image = UIImage(named:"backButton"){
    let backImage = image.withRenderingMode(.alwaysOriginal).resizableImage(withCapInsets: UIEdgeInsetsMake(image.size.height, image.size.width, 0, 0))
    UIBarButtonItem.appearance().setBackButtonBackgroundImage(backImage, for: .normal, barMetrics: .default)
    UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-400, 0), for: .default)
}

(斯威夫特 3)

这篇关于更新整个项目的导航栏后退按钮图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆