当前位置: 首页 > 编程日记 > 正文

ios单应用模式_如何为iOS 13暗模式设置应用

ios单应用模式

Apple launched the much-awaited iOS 13 updates globally on September 19 across all iPhones launched within the past 4 years (back to the iPhone 6s).

苹果于9月19日在全球发布了期待已久的iOS 13更新,该更新适用于过去4年内发布的所有iPhone(返回iPhone 6s)。

One of the biggest features of this update was the system-wide iOS 13 dark mode. It's expected to help with eye-strain caused by white light emitted by smartphone displays.
此更新的最大功能之一是系统范围的iOS 13暗模式。 它有望帮助缓解由智能手机显示屏发出的白光引起的眼睛疲劳。

While this feature is a joy to end-consumers using Apple devices, it's a task for iOS developers to prepare an app ready for iOS 13 dark mode.

虽然此功能对于使用Apple设备的最终用户而言是一种乐趣,但iOS开发人员的任务是准备可用于iOS 13暗模式的应用程序。

如何为iOS 13黑暗模式设置您的应用程序? (How to Set up your App for iOS 13 Dark Mode?)

To help developers with this issue, here is useful info and steps showing how they can prep up an existing iOS app for iOS 13 dark mode.

为帮助开发人员解决此问题,此处提供了有用的信息和步骤,显示了他们如何为iOS 13暗模式准备现有的iOS应用。

  • It’s not too hard to implement iOS 13 dark mode despite its system-wide scale.

    尽管它具有系统范围的规模,但实现iOS 13黑暗模式并不难。
  • Enabling iOS 13 dark mode on your existing app is also simple mostly thanks to the latest iOS 13 SDK.

    由于最新的iOS 13 SDK,在现有应用程序上启用iOS 13暗模式也很简单。

When using the latest version to build apps for iOS 13 dark mode, the OS will automatically update switches, buttons, and table views among other system controls. Though do note that images and text colors won’t adjust for dark mode automatically.

使用最新版本为iOS 13暗模式构建应用程序时,操作系统将自动更新其他系统控件中的开关,按钮和表格视图。 不过请注意,图片和文字颜色不会自动调整为暗模式。

However, it’s still amazing to see that a system-wide change such as dark mode is so easy to implement. There are smaller code changes and more work that you'll be able to get done with the iOS 13 dark mode in that saved time.

但是,令人惊奇的是,系统范围的更改(如暗模式)如此容易实现。 在节省的时间内,使用iOS 13暗模式可以进行更小的代码更改和更多的工作。

如何为iOS 13深色模式调整颜色 (How to Adapt Colors For iOS 13 Dark Mode)

First, let’s start with changing system colors iOS 13 dark mode:

首先,让我们从更改系统颜色iOS 13暗模式开始:

Now there are new system colors added in UIColor, one of which is a label color. Using these new colors helps support dark mode and other high contrast modes in iOS 13.

现在,UIColor中添加了新的系统颜色,其中一种是标签颜色。 使用这些新颜色有助于在iOS 13中支持暗模式和其他高对比度模式。

label.color = UIColor.secondaryLabel

Generally, you should use system colors for iOS 13 dark mode, which automatically adapts to changes in the interface for maintaining consistency across apps. However, developers can also choose to implement dark mode with custom colors.

通常,您应该为iOS 13深色模式使用系统颜色,该颜色会自动适应界面更改,以保持应用程序之间的一致性。 但是,开发人员还可以选择使用自定义颜色实现暗模式。

The asset catalog colors introduced with iOS 11 make it much easier to support dark mode by adding dark versions of a custom set of colors.
通过添加自定义颜色组的深色版本,iOS 11引入的资产目录颜色使支持深色模式更加容易。

You only have to select a preferred color from the catalog, then change Appearances to Any, Dark from the Attributes Inspector.

您只需从目录中选择一种首选颜色,然后从“属性”检查器中将“外观”更改为“任意,深色”。

That's it! Now you have a custom iOS 13 dark mode ready for your mobile app.

而已! 现在,您已经为移动应用程序准备了自定义iOS 13暗模式。

对iOS 13暗模式进行故障排除 (Troubleshooting iOS 13 Dark Mode )

Let's say your app is not following iOS 13 dark mode. What will you do? Here are some easy steps to solve this issue.

假设您的应用未遵循iOS 13暗模式。 你会怎么做? 以下是解决此问题的一些简单步骤。

第1步 (Step 1)

You will need to know if the app is updated or not.

您将需要知道该应用程序是否已更新。

If the app is not working with iOS 13 Dark Mode or does not support it, simply update the app via Apple Store.

如果该应用程序无法在iOS 13暗模式下使用或不支持它,只需通过Apple Store更新该应用程序。

第2步 (Step 2 )

Check whether the Dark Mode of your iOS app has been enabled or not.

检查您的iOS应用的黑暗模式是否已启用。

If not, go to Settings - Display & Brightness - check whether "Dark" is enabled or not.

如果不是,请转到设置-显示和亮度-检查是否启用了“暗”。

第三步 (Step 3  )

If your app is fully updated, but isn't working with iOS 13 Dark Mode, then check the in-app settings. See the image:

如果您的应用程序已完全更新,但不能在iOS 13暗模式下使用,请检查应用程序内设置。 见图片:

If you want more help on setting up your iOS 13 Dark Mode, get it from the dedicated development teams. And, that is how I'm going to help you.

如果您需要更多有关设置iOS 13暗模式的帮助,请从专门的开发团队获得 。 而且,这就是我将如何帮助您。

Also read tips for mobile app development on iOS. Hope all this information will be helpful for you.

另请阅读有关在iOS上进行移动应用开发的提示。 希望所有这些信息对您有所帮助。

Let's see what you have to do next.

让我们看看您接下来要做什么。

为iOS 13暗模式调整图像 (Adapt Images For iOS 13 Dark Mode)

Most images look great in iOS 13 dark mode, and at times they pop out in a way that really highlights details. However, you may still end up finding some images which look a bit off or unsuitable for dark mode.

大多数图像在iOS 13暗模式下看起来很棒,有时会以突出显示细节的方式弹出。 但是,您仍然可能最终会发现一些看起来有些偏离或不适合黑暗模式的图像。

The good news is that you can adjust images for dark mode in the same way text is adjusted.
好消息是,您可以以调整文本的相同方式将图像调整为暗模式。

All you need to do is select the image in the catalog and as done previously, and change attributes to Any, Dark in the Attributes Inspector. Now add the dark appearance of the image and we’re done.

您需要做的就是选择目录中的图像,并像以前一样进行操作,然后在“属性”检查器中将属性更改为“任意,黑暗”。 现在添加图像的深色外观,我们完成了。

以编程方式在iOS 13暗模式下检测更改 (Programmatically Detecting Changes in iOS 13 Dark Mode)

Developers could face situations where they need to implement appearance changes in iOS 13 dark mode programmatically. This is how it's done:

开发人员可能会遇到需要以编程方式在iOS 13暗模式下实现外观更改的情况。 这是这样做的:

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) 
{super.traitCollectionDidChange(previousTraitCollection)let userInterfaceStyle = traitCollection.userInterfaceStyle // Either .unspecified, .light, or .dark// Update your user interface based on the appearance
}
Overriding traitCollectionDidChange helps in detecting appearance changes.
覆盖traitCollectionDidChange有助于检测外观变化。
Then we only have to open traitCollection.userInterfaceStyle.
然后,我们只需要打开traitCollection.userInterfaceStyle。

You can also verify if the existing appearance is using a new method you just implemented:

您还可以验证现有外观是否正在使用刚实现的新方法:

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {super.traitCollectionDidChange(previousTraitCollection)let hasUserInterfaceStyleChanged = previousTraitCollection.hasDifferentColorAppearance(comparedTo: traitCollection) // Bool// Update your user interface based on the appearance
}

覆盖用户界面样式 (Overriding the User Interface Style)

完整的应用程序 (Complete App)

The system automatically opts-in any app linked against the iOS 13.0 or later SDK to both light and dark appearances.

系统会自动选择将与iOS 13.0或更高版本的SDK链接的任何应用程序显示为浅色和深色。

If you need extra time to work on your app’s Dark Mode support or want to keep your app in a single style, you can opt-out by including the UIUserInterfaceStyle key (with a value of Light or Dark) in your app’s Info.plist file.

如果您需要更多时间来处理应用程序的“暗模式”支持,或者希望使应用保持单一样式,则可以通过在应用的Info.plist文件中包含UIUserInterfaceStyle键(值为Light或Dark)来选择退出。

Setting this key causes the system to ignore the user’s preference and always apply the specific appearance to your app.

设置此键会导致系统忽略用户的偏好,并始终将特定外观应用于您的应用。

Note: Supporting iOS 13 Dark Mode is strongly encouraged. Use the UI UserInterfaceStyle key to opt-out only temporarily while you work on improvements to your app’s Dark Mode support.

注意:强烈建议支持iOS 13黑暗模式。 在改进应用程序的暗模式支持时,请使用UI UserInterfaceStyle键仅暂时退出。

特定画面 (Specific Screens)

In iOS 13, you can now override the user interface style on specific views or view controllers. For example, you may want only a certain view controller to be in iOS 13 dark mode, while the rest of your app is in light mode.

在iOS 13中,您现在可以在特定视图或视图控制器上覆盖用户界面样式。 例如,您可能只希望某个视图控制器处于iOS 13暗模式,而其他应用程序处于亮模式。

To override the user interface style, just override this variable in the top view or view controller and it will propagate down to sub-views:

要覆盖用户界面样式,只需在顶视图或视图控制器中覆盖此变量,它将向下传播到子视图:

// Inside a UIViewController
override func viewDidLoad() 
{super.viewDidLoad()// Always adopt a dark interface style.    overrideUserInterfaceStyle = .dark
}

结束语 (Closing Notes)

Thanks for reading the article! Here we've explored how to set up an app for iOS 13 dark mode.

感谢您阅读本文! 在这里,我们探讨了如何为iOS 13暗模式设置应用。

iOS 13 dark mode brings with it a unique stress-free way to use a smartphone. Perhaps we’ll see a future where dark mode replaces the default mode with the whiter backgrounds.

iOS 13黑暗模式带来了独特的无压力使用智能手机的方式。 也许我们会看到黑暗模式将默认模式替换为白色背景的未来。

By following these coding guidelines and tips you can easily set up your app for dark mode on iOS 13.

通过遵循这些编码准则和提示,您可以轻松地在iOS 13上将应用设置为暗模式。

If you need some expert help, feel free to get in touch with iOS developers for iOS 13 dark mode related queries.  

如果您需要一些专家帮助,请随时与iOS开发人员 联系以进行有关iOS 13暗模式的查询。

Follow on Twitter for more updates: https://twitter.com/ValueCoders

在Twitter上关注以获取更多更新: https //twitter.com/ValueCoders

翻译自: https://www.freecodecamp.org/news/how-to-setup-an-app-for-dark-mode-on-ios-13-untitled/

ios单应用模式

相关文章:

BZOJ1965 [Ahoi2005]SHUFFLE 洗牌 快速幂

欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1965 题意概括 对于扑克牌的一次洗牌是这样定义的,将一叠N(N为偶数)张扑克牌平均分成上下两叠,取下面一叠的第一张作为新的一叠的第一张&#xff0c…

uniapp 长链接 socket 封装

App.vue <script>import socket from @/util/IM.jsexport default {watch: {$route: function() {var page = getCurrentPages();console.log(watch-监听路由, page);}},globalData: {ImAuth: socket.connect(),},onLaunch: function(e) {},onShow: function() {socket.…

react项目开发步骤_成为专业React开发人员的31个步骤

react项目开发步骤我为达到可雇用水平而进行的每个项目和课程。 (Every single project and course I took to reach a hireable level.) Before I learned how to code, I used to ask developers how much time it took them to learn their craft — and how they managed t…

P1979 [NOIP]华容道

【问题描述】 小 B 最近迷上了华容道&#xff0c;可是他总是要花很长的时间才能完成一次。于是&#xff0c;他想到用编程来完成华容道&#xff1a;给定一种局面&#xff0c; 华容道是否根本就无法完成&#xff0c;如果能完成&#xff0c; 最少需要多少时间。 小 B 玩的华容道与…

JS计算两个时间相差多久,相差年,月,日,小时,分钟

计算一个时间戳距离当前的时间&#xff0c;例如&#xff1a; 几年前&#xff0c;几个月前&#xff0c;几天前&#xff0c;几小时前&#xff0c;几分钟前&#xff0c;刚刚。 输出效果 代码&#xff1a; function getDistanceDay(time) {let stime new Date().getTime();let u…

replace 使用函数作为第二参数

var sToChange “The sky is red.”;var reRed /red/;var sResultText sToChange.replace(reRed, function(sMatch) { return “blue”;}); sMatch 指的是被匹配到到的对象&#xff0c; return 返回替换的对象 var reBadWords /badword|anotherbadword/gi;var sU…

如何在Visual Studio Code中编译C ++代码

PS: This was published on my Blog here. PS&#xff1a;这已发布在我的Blog 此处 。 C is a statically-typed, free-form, (usually) compiled, multi-paradigm, intermediate-level general-purpose middle-level programming language.C 是一种静态类型的&#xff0c;自由…

敏捷冲刺每日报告四(Java-Team)

第四天报告&#xff08;10.28 周六&#xff09; 团队&#xff1a;Java-Team 成员&#xff1a; 章辉宇&#xff08;284&#xff09; 吴政楠&#xff08;286&#xff09; 陈阳&#xff08;PM&#xff1a;288&#xff09; 韩华颂&#xff08;142&#xff09; 胡志权&#xff08;1…

终止forEach的循环

上代码&#xff1a; let list[1,2,3] try {list.forEach(item > {if (item1) {console.log(等于1就跳出循环)throw new Error("EndIterative");}}) } catch (e) {}

大学可以学前端开发_所有开发人员在大学中应该学习的东西

大学可以学前端开发忘记“代码行” (Forget About "Lines of Code") Source资源 As a developer, youll hear a lot of crazy, unbelievable theories about what "lines of code" signify. Believe none of them. Lines of code is a ridiculous metric …

20162325 金立清 S2 W8 C17

20162325 2017-2018-2 《程序设计与数据结构》第8周学习总结 教材学习内容概要 二叉查找树是一棵二叉树&#xff0c;对于其中的每个结点&#xff0c;左子树上的元素小于父结点的值&#xff0c;而右子树上的元素大于等于父结点的值。 最有效的二叉树是平衡的&#xff0c;所以每次…

H5画布不显示图片的问题解决

在onReady 执行 <template><view class""><canvas style"" canvas-id"myCanvas" id"myCanvas"></canvas><!-- <view class"container"><img :src"tempFilePath" /></…

javascript十六进制数字和ASCII字符之间转换

var hex"0x29";//十六进制 var charValue String.fromCharCode(hex);//生成Unicode字符 var charCode charValue.charCodeAt(0);//获取指定字符的十进制表示. var hexOri"0x"charCode.toString(16);;//将int值转换为十六进制 alert("hex:&q…

html5编写网页代码_freeCodeCamp.org的未来-从向世界传授语言到编写代码的5年经验...

html5编写网页代码freeCodeCamp went live in October 2014. In the five years since, weve done quite a bit.freeCodeCamp于2014年10月上线。在此之后的五年中&#xff0c;我们做了很多工作。 In this article, well explore:在本文中&#xff0c;我们将探讨&#xff1a; …

程序员眼中的英文单词是这样的

来源&#xff1a;Jackie Han英语中一个单词可能有很多不同的意思。很多中国开发者外语本来就不好&#xff0c;概念是往往先入为主。甚至在不清楚一般意义的情况下&#xff0c;先记住了特定环境中的意思。 转载于:https://www.cnblogs.com/agileai/p/5166982.html

linux系统无法挂载U盘

插上U盘 [ 2407.650440] usb 1-3.3: new high speed USB device number 7 using s5p-ehci [ 2407.887332] usb 1-3.3: New USB device found, idVendor0951, idProduct1666, bcdDevice0100 [ 2407.894249] usb 1-3.3: New USB device strings: Mfr1, Product2, SerialNumber3 […

小程序输入框上推页面不上推

样式问题&#xff0c;把样式去掉就行

面试:你了解中兴吗_HTTP简介:您需要了解的所有内容

面试:你了解中兴吗In this article, I will walk you through how the world wide web works at a fundamental level.在本文中&#xff0c;我将向您介绍基本的万维网工作原理。 The core technology is HTTP - Hypertext Transfer Protocol. Its the communication protocol …

img-responsive class图片响应式

在BootStrap中&#xff0c;给<img>添加 .img-responsive样式就可以实现图片响应式。1<img src"..." class"img-responsive">转载于:https://www.cnblogs.com/zouyun/p/7761393.html

小程序开发卡券

前期准备 小程序内领取卡券 1.开发者须有一个有卡券权限的公众号&#xff08;服务号&#xff09;和认证后的小程序账号&#xff1b; 2.开发者须申请一个开放平台账号&#xff0c;并将小程序和公众号绑定在同一个开放平台账号下&#xff0c;关于开放平台的介绍请参照&#xff1…

php学习之道:WSDL具体解释(三)

通过声明方式定义绑定&#xff08;binding&#xff09;属性 假设你在服务中採用SOAP binding。你能够使用JAX-WS来指定一定数量的属性binding。这些属性指定相应你在WSDL中指定的属性。某些设置。比方參数类型&#xff0c;能够约束你实现的方法。这些设置也影响声明的效用。 SO…

什么是棉绒,它如何节省您的时间?

One of the biggest challenges in software development is time. It’s something we can’t easily get more of, but linting can help us make the most out of the time we have.时间是软件开发中最大的挑战之一。 这是我们无法轻易获得的更多东西&#xff0c;但是棉绒可…

可持久化线段树(主席树)【舰娘系列】【自编题】

[pixiv] https://www.pixiv.net/member_illust.php?modemedium&illust_id60083619 向大(hei)佬(e)势力学(di)习(tou) 前段时间做了一套大佬自己出的题&#xff08;大佬竟然是个宅男2333&#xff09;&#xff0c;蒟蒻的我自然是只得了30分的暴力分:-( fleet 舰队 【题目描…

读书笔记——《黑客大曝光》(1/8)

第一部分 收集情报 案例研究 Tor系统基于洋葱路由器&#xff0c;是第二代低延迟匿名系统&#xff0c;用户可通过它在互联网上进行匿名通信。Tor网络的使用者必须在他们的系统上运行一个洋葱代理&#xff0c;这个代理允许它们在Tor网络上进行通信&#xff0c;并协商一个虚拟链路…

H5 自动播放背景音频,兼容安卓和苹果手机, ios createInnerAudioContext 无法自动播放解决

原因应该是IOS不允许自动播放音频,有两种解决方法 在main.js Vue.prototype.innerAudioContext = uni.createInnerAudioContext(); //创建播放器对象 Vue.prototype.playAudio = function(audioUrl) {console.log(播放)var innerAudioContext = Vue.prototype.innerAudioCont…

粒子耗尽 粒子滤波_如何使用粒子的强大蓝牙API

粒子耗尽 粒子滤波This post is originally from www.jaredwolff.com 这篇文章最初来自www.jaredwolff.com I was defeated. 我被打败了。 I had spent the whole night trying to get a Bluetooth Low Energy project working. It was painful. It was frustrating. I was r…

Android笔记(adb命令--reboot loader)

Android 的机器通过adb进入升级模式的方法 # adb shell # reboot loader 通过上面两个命令就进入升级模式了&#xff0c;通过工具升级就好了 为什么会写这简单的一篇呢&#xff1f;因为今天干了一件很傻很傻的事&#xff0c;特别记录下来。 业务那边今天急着要把机器寄给客户&a…

样式集(八)弹窗,规则弹窗,半透明弹窗

效果图&#xff1a; 代码&#xff1a; <view class"popupBlock" v-if"showPopupBlock"><view class"xxx"><image class"xxxImg" click"showPopupBlockfalse" mode"widthFix" src"../../stat…

typeof操作符的返回值

使用typeof操作符 对一个值使用typeof操作符可能返回下列某个字符串: 1):undefined——如果这个值未定义 2):boolean——如果这个值是布尔值 3):string——如果这个值是字符串 4):number——如果这个值是数值 5):object——如果这个值是对象或null&#xff0c;数组&#xff0c;…

定制开发软件所有权_职业所有权软件开发人员指南

定制开发软件所有权介绍 (Introduction) 您的职业正在流向大海吗&#xff1f; (Is Your Career Drifting Out To Sea?) Like a frog whos slowly being boiled in a pot but doesnt realize it, 2 years into my career I slowly came to discover that I wasnt progressing a…