关键词:
【中文标题】升级到 XCode 13(和 iOS 15)后选项卡和导航栏发生变化【英文标题】:Tab & Navigation Bar changes after upgrading to XCode 13 (& iOS 15) 【发布时间】:2021-11-15 18:04:06 【问题描述】:我有一个 iOS 应用,自从升级到 Xcode 13 后,我注意到 Tab 和 Navigation 栏有一些特殊的变化。在 Xcode 13 中,现在选项卡和导航栏上有这个黑色区域,在启动应用程序时,选项卡栏和导航栏现在都是黑色的。很奇怪,如果视图有滚动或表格视图,如果我向上滚动,底部标签栏会恢复为白色,如果我向下滚动,导航栏会恢复为白色。
N:B:我已经从 iOS 13 及更高版本强制使用浅色主题:
if #available(iOS 13.0, *)
window!.overrideUserInterfaceStyle = .light
任何人都可以帮助或指出正确的方向以处理这种特殊性吗?
是否有一个简单的修复方法可以让 Storyboard 重新调整,或者这是我必须手动更改每个视图的情况?
升级前的故事板示例:
之后:
(分别)升级前后的模拟器画面:
【问题讨论】:
【参考方案1】:您可以通过选择选项卡栏在情节提要中执行此操作,并在属性检查器中选择标准和滚动边缘外观,将它们的设置设置为与 iOS 13 一样,对于自定义字体或颜色,您需要将标准布局外观堆叠为自定义和设置属性。
对于导航栏,您可以在 Attributes Inspector 中类似地设置 Standard 和 Scroll Edge Appearances,但这已在堆栈溢出的其他地方提到。
【讨论】:
如果您的应用支持,这将导致 iOS12 及以下版本崩溃。【参考方案2】:对我来说,我在使用 Navbar 和 TabBar 时都遇到了问题,所以我在 AppDelegate
中全局应用了这些样式
func configureNavigationBarAppearance()
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .white
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
func configureTabBarAppearance()
let appearance = UITabBarAppearance()
appearance.backgroundColor = .white
UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = appearance
【讨论】:
简单而宏伟的解决方案...【参考方案3】:更新到 XCode 13 和 iOS 15 后,我还遇到了一些选项卡栏问题,这些问题涉及不同状态的栏背景颜色和项目文本颜色。我修复它的方式:
if #available(iOS 15, *)
let tabBarAppearance = UITabBarAppearance()
tabBarAppearance.backgroundColor = backgroundColor
tabBarAppearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: selectedItemTextColor]
tabBarAppearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: unselectedItemTextColor]
tabBar.standardAppearance = tabBarAppearance
tabBar.scrollEdgeAppearance = tabBarAppearance
else
UITabBarItem.appearance().setTitleTextAttributes([.foregroundColor: selectedItemTextColor], for: .selected)
UITabBarItem.appearance().setTitleTextAttributes([.foregroundColor: unselectedItemTextColor], for: .normal)
tabBar.barTintColor = backgroundColor
【讨论】:
【参考方案4】:我的问题解决了,把右边的导航栏换成你想要的颜色
navigationController?.navigationBar.backgroundColor = .lightGray
【讨论】:
【参考方案5】:关于导航栏是黑色的,试试看:
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .red
appearance.titleTextAttributes = [.font:
UIFont.boldSystemFont(ofSize: 20.0),
.foregroundColor: UIColor.white]
// Customizing our navigation bar
navigationController?.navigationBar.tintColor = .white
navigationController?.navigationBar.standardAppearance = appearance
navigationController?.navigationBar.scrollEdgeAppearance = appearance
我写了一篇关于它的新文章。
https://medium.com/@eduardosanti/uinavigationbar-is-black-on-ios-15-44e7852ea6f7
【讨论】:
感谢@Eduardo Santi,上面的解决方案有效,在我的情况下,将 isTranslucent 设置为 true 也有效,至于标签栏,我已经指定了背景颜色【参考方案6】:首先问题是取消选中半透明引起的 我通过从属性检查器滚动边缘选择导航栏外观来修复它 它会修复它see this screen shot please
【讨论】:
有趣的是,在我这端,实际上检查半透明解决了一半的问题 我知道有多乱:Dxcode13.0和ios15.0适配(代码片段)
...juejin.cn/post/7018495854168244260看了掘友的文章后,今天才升级xcode13,跑了一下老项目,发现不少 查看详情
升级到 Xcode 4.2 和 iOS5 后,应用程序无法在 iPhone 上运行
】升级到Xcode4.2和iOS5后,应用程序无法在iPhone上运行【英文标题】:Appsdon\'trunoniPhoneafterupgradingtoXcode4.2andiOS5【发布时间】:2011-12-1410:35:15【问题描述】:自从升级到Xcode4.2和iOS5后,我无法再在我的iPhone上运行我的应用程序。他... 查看详情
IOS15 升级后 Iframe 内容未加载到 Iphone 中
】IOS15升级后Iframe内容未加载到Iphone中【英文标题】:IframecontentnotloadinginIphoneafterIOS15upgrade【发布时间】:2021-11-1021:13:03【问题描述】:我们在iframe中嵌入了一个自定义应用程序,并且iframe内的内容在ios升级到ios15后不会仅在Iphon... 查看详情
升级到 Xcode 8 和 Swift 3.0 后使用 Google Places iOS SDK 出现无法解释的异常
】升级到Xcode8和Swift3.0后使用GooglePlacesiOSSDK出现无法解释的异常【英文标题】:UnexplainedexceptionusingtheGooglePlacesiOSSDKafterupgradetoXcode8andSwift3.0【发布时间】:2016-09-1617:37:13【问题描述】:在将其转换为swift3.0后,我什至无法让演示代... 查看详情
升级到新的 Xcode 12 时出错
】升级到新的Xcode12时出错【英文标题】:GettingErrorwhileupgradingtonewXcode12【发布时间】:2020-09-3014:56:11【问题描述】:我的应用正在使用CoreLocation和CLLocationManager,并且在iOS13和iOS12中运行良好。我已经使用Xcode12在iOS14中实现了精确... 查看详情
在 Xcode 13.1 和 iOS 15 上测试 Unity 游戏时的奇怪行为
】在Xcode13.1和iOS15上测试Unity游戏时的奇怪行为【英文标题】:WeirdbehaviorwhiletestingUnitygameonXcode13.1andiOS15【发布时间】:2021-12-2910:23:51【问题描述】:我正在使用Unity开发游戏,一切正常,直到我在运行iOS15.1(通过Xcode13.1)的iPhone... 查看详情
升级到 Xcode 10.0 后无法构建模块“UIKit”
】升级到Xcode10.0后无法构建模块“UIKit”【英文标题】:Couldnotbuildmodule\'UIKit\'afterupgradetoXcode10.0【发布时间】:2018-10-0117:07:17【问题描述】:升级到Xcode10.0后,我的iOS项目将无法构建。与UIKit相关的2个特定构建时错误是:解析问... 查看详情
升级到 Xcode 5.1 和 iOS 7.1 后,在 segue 过渡期间导航栏上出现暗影
】升级到Xcode5.1和iOS7.1后,在segue过渡期间导航栏上出现暗影【英文标题】:DarkshadowonnavigationbarduringseguetransitionafterupgradingtoXcode5.1andiOS7.1【发布时间】:2014-04-2005:28:12【问题描述】:当我在主-详细导航控制器中的父控制器和子控... 查看详情
升级到 Xcode 4.2/iOS 5 后,类别中的方法引发异常
】升级到Xcode4.2/iOS5后,类别中的方法引发异常【英文标题】:MethodfromacategorythrowsanexceptionafterupgradetoXcode4.2/iOS5【发布时间】:2011-10-1406:02:55【问题描述】:我有一个使用shuffle方法扩展NSMutableArray的类别。该类别在.h文件中声明和... 查看详情
升级到 xcode 4.6 和 iOS 6.1 后出错“用作前一个参数的名称,而不是作为选择器的一部分”
】升级到xcode4.6和iOS6.1后出错“用作前一个参数的名称,而不是作为选择器的一部分”【英文标题】:Errorafterupgradingtoxcode4.6andiOS6.1"usedasthenameofthepreviousparameterratherthanaspartoftheselector"【发布时间】:2013-01-1216:52:26【问题描... 查看详情
Xcode 13 - 缺少 IOS 15 模拟器?
】Xcode13-缺少IOS15模拟器?【英文标题】:Xcode13-MissingIOS15simulator?【发布时间】:2021-10-1116:41:59【问题描述】:我刚刚安装了Xcode13-主要是为了测试IOS15上的一些功能。但是我注意到模拟器列表中缺少IOS15。猜我错过了添加ios15模拟... 查看详情
SmartConfig 在升级到 Xcode 12.5 后停止工作
】SmartConfig在升级到Xcode12.5后停止工作【英文标题】:SmartConfigstoppedworkingafterupgradetoXcode12.5【发布时间】:2021-06-1605:25:09【问题描述】:使用ESPTouch框架的我的iOS应用程序不再工作-它编译没有错误,但SmartConfig似乎不再到达ESP32。... 查看详情
升级到 Xcode 10 后,无法快速识别 Objective C 类
】升级到Xcode10后,无法快速识别ObjectiveC类【英文标题】:ObjectiveCclassescannotberecognizedinswiftafterupgradetoXcode10【发布时间】:2018-09-2610:19:32【问题描述】:我有一个由Swift4和ObjectiveC开发的iOS项目,使用Xcode9时一切正常。XCode升级到1... 查看详情
升级到 XCode 4.3 后 FPS 下降
】升级到XCode4.3后FPS下降【英文标题】:FPSDropafterupgradingtoXCode4.3【发布时间】:2012-04-2517:33:24【问题描述】:我希望其他人经历过这种情况并随后找到解决方案,因为我正沮丧地点燃自己的头发。简单地说,我正在使用XCode3.2.6... 查看详情
如何在 Xcode 13 / iOS 15 中测量能源使用情况?
】如何在Xcode13/iOS15中测量能源使用情况?【英文标题】:HowtomeasureenergyusageinXcode13/iOS15?【发布时间】:2021-11-2002:18:19【问题描述】:我想确认我正在iOS上开发的应用程序的电池使用情况,特别是在Xcode13和iOS15上。(注意:此应... 查看详情
Xamarin.iOS SKProductRequest 事件未在 Debug 中调用(在 iOS 15 和 xCode 13 之前工作)
】Xamarin.iOSSKProductRequest事件未在Debug中调用(在iOS15和xCode13之前工作)【英文标题】:Xamarin.iOSSKProductRequesteventsarenotcalledinDebug(workedbeforeiOS15andxCode13)【发布时间】:2021-10-1921:03:00【问题描述】:我们在Live中有一个iPhone/iPad应用程... 查看详情
Xcode 8 不包括 iOS 10
...时间】:2016-09-1710:56:15【问题描述】:我刚刚通过AppStore升级到Xcode8,但在任何地方都找不到iOS10模拟器。当我启动模拟器时,它正在运行iOS8.4,如果我选择“下载模拟器”,我只能获得最高iOS9.3的选项。阅读其他线程后,似乎... 查看详情
animateWithDuration 在升级到 xcode 4.6 后导致 ios4 上的触摸事件出现问题
】animateWithDuration在升级到xcode4.6后导致ios4上的触摸事件出现问题【英文标题】:animateWithDurationcausingproblemswithtoucheventsonios4afterupgradetoxcode4.6【发布时间】:2013-02-2423:57:44【问题描述】:在升级到xcode4.6之前,我有一个运行良好的... 查看详情