我有一个简单的故事板,在导航视图控制器中有一个表视图,从表视图推送到另一个具有全屏图像视图的视图控制器.表视图的导航栏中有一个提示文本.当我点击表格视图中的表格视图单元格时,我会收到以下警告.我根本没有自定义后退按钮.我创建了一个展示问题的示例项目.
https://github.com/stevemoser/UIBarButtonItemCustomizationWarningExampleProject
任何人都知道为什么我收到这个警告?
将忽略UIBarButtonItem自定义UIBarMetricsDefaultPrompt或UIBarMetricsLandscapePhonePrompt的后退按钮背景图像.
我setBackButtonTitlePositionAdjustment:forBarMetrics:在 UIBarButtonItem 的外观上使用该方法,如下所示:
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(12, -1), forBarMetrics: .Default)
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(15, -1), forBarMetrics: .Compact)
Run Code Online (Sandbox Code Playgroud)
然后,在视图控制器中我想用来backButtonTitlePositionAdjustment(for:)获取该值。我假设必须有一个我可以使用的 UIBarMetrics 值 - 也许在导航栏或 UITraitCollection 中,但我认为我错过了一些明显的东西?
我正在使用swift来制作IOS应用程序.我有一个UIToolBar在我的应用程序中,我需要更改其背景.我在Objective-C中使用以下代码来做到这一点:
[topBar setBackgroundImage:[UIImage imageNamed:@"header_bg.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
现在,当我在swift中重写代码时,它看起来像这样:
topBar.setBackgroundImage(UIImage(named:"header_bg.png"), forToolbarPosition: UIToolbarPositionAny, barMetrics: UIBarMetricsDefault)
Run Code Online (Sandbox Code Playgroud)
这显示的错误,Use of unresolved type UIBarMetricsDefault和Use of unresolved type UIToolbarPositionAny.所以我做了一个搜索并找到了这个文档.根据文档,我改变了这样的代码:
topBar.setBackgroundImage(UIImage(named:"header_bg.png"), forToolbarPosition: Any, barMetrics: Default)
Run Code Online (Sandbox Code Playgroud)
但它仍然显示相同的错误.任何人都知道这里有什么问题吗?