简体   繁体   English

将图像添加到导航栏后退按钮

[英]Add image to Navigation Bar Back Button

I want to have the back button with "< [IMG]" instead of "< Back" which is by default. 我希望后退按钮带有“<[IMG]”而不是默认的“<Back”。

let barAppearace = UIBarButtonItem.appearance()
barAppearace.setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), for:UIBarMetrics.default)

with this I have removed the text but how to add an image next to the "<". 有了这个,我删除了文本,但如何在“<”旁边添加图像。

let backButton = UIBarButtonItem(image:UIImage(named: "ic_authors_detail_back.png"), style:.Plain, target:self, action:"backButtonPressed");
backButton.tintColor = UIColor(hexString: "#ffffffff")
let leftBarButtonsArray = [backButton]
navigationItem.leftBarButtonItems = leftBarButtonsArray

Here is the code to add a button on navigation bar.Hope this helps 这是在导航栏上添加按钮的代码。希望这有帮助

When you click left bar button 单击左侧栏按钮时

在此输入图像描述

You can set its attribute like: 您可以将其属性设置为:

在此输入图像描述

Here is option to set image. 这是设置图像的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM