<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
	<channel>
		<title>How to Prepare Your App for Dark Mode in iOS 13 | Infinum</title>
		<atom:link href="https://infinum.com/blog/how-to-prepare-your-app-for-dark-mode-in-ios-13/feed/" rel="self" type="application/rss+xml" />
		<link>https://infinum.com/blog/how-to-prepare-your-app-for-dark-mode-in-ios-13/</link>
		<description>Building digital products</description>
		<lastBuildDate>Fri, 03 Apr 2026 12:58:20 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>

					<item>
				<image>
					<url>7934https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-0.webp</url>
				</image>
				<title>How to Prepare Your App for Dark Mode in iOS 13</title>
				<link>https://infinum.com/blog/how-to-prepare-your-app-for-dark-mode-in-ios-13/</link>
				<pubDate>Fri, 13 Sep 2019 13:15:00 +0000</pubDate>
				<dc:creator>Goran Brlas</dc:creator>
				<guid isPermaLink="false">https://infinum.com/the-capsized-eight/how-to-prepare-your-app-for-dark-mode-in-ios-13/</guid>
				<description>
					<![CDATA[<p>After what seems like forever, iOS is officially getting a feature its users have been crying for: a system-wide dark mode.</p>
<p>The post <a href="https://infinum.com/blog/how-to-prepare-your-app-for-dark-mode-in-ios-13/">How to Prepare Your App for Dark Mode in iOS 13</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</description>
				<content:encoded>
					<![CDATA[<div
	class="wrapper"
	data-id="es-382"
	 data-animation-target='inner-items'>
		
			<div class="wrapper__inner">
			<div class="block-blog-content js-block-blog-content">
	
<div class="block-blog-content-sidebar" data-id="es-92">
	</div>

<div class="block-blog-content-main">
	
<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-95"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-93">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-94'
	>
	After waiting for what seems like an eternity, iOS is officially getting a feature its users have been crying for: a system-wide dark mode. As it sees the light of day, Android users should finally stop gloating over their advantage!</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-98"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-96">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-97'
	>
	The wait has been long but it’s been worth it. Dark mode suits iOS well, as is evident from the settings app screenshot below.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-101"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-99"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-auto" data-id="es-100">
	<picture class="image__picture block-media__image-picture">
								
			<source
				srcset=https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-1-1400x875.webp				media='(max-width: 699px)'
				type=image/webp								height="875"
												width="1400"
				 />
												<img
					src="https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-1.webp"
					class="image__img block-media__image-img"
					alt=""
										height="1000"
															width="1600"
										loading="lazy"
					 />
					</picture>

	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-104"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-102">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-103'
	>
	Beg to differ? Well, even if you’re not digging the new color scheme, you should still try it out as it’s not only a visual update–it comes with more hidden benefits.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-107"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-105">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-106'
	>
	Dark mode can help <strong>preserve battery life on OLED screens</strong> since true black (#000000) color means turned off pixels. It’s not much, but if you need every little bit of the energy juice available, it’s worth considering. Also, late-night texters will appreciate the dark color causing <strong>less strain</strong> than default white.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-110"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-108">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-109'
	>
	Chances are these benefits have sparked the interest of mobile users, so in this article we’ll cover everything you need to know in order to <strong>make your app a dark mode native</strong>.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-113"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-111">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-112'
	>
	By the way, adding dark mode support becomes much easier when you put our <a href="https://infinum.com/blog/color-naming-system-ios/" target="_blank" rel="noreferrer noopener">Bullet-Proof Color-Naming System for iOS Development</a> to use. </p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-116"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-114">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-115'
	>
	Requirements</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-119"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-117">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-118'
	>
	Before diving in, there are a couple of requirements you must meet in order to actually make your app dark-mode compliant.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-122"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="lists" data-id="es-120">
	<ul	class='typography typography--size-16-text-roman js-typography lists__typography'
	data-id='es-121'
	>
	<li>It must be built and released using <strong>Xcode 11</strong></li><li>It must run on a device running <strong>iOS 13.0 or later</strong></li></ul></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-125"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-123">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-124'
	>
	If you built your app using any older Xcode, the app will always display its normal appearance, even on devices which support dark mode. The exact same is true for apps built using Xcode 11 but running on older versions of iOS–these new features will not apply and the app will retain its default appearance.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-128"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-126">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-127'
	>
	Getting our hands dirty</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-131"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-129">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-130'
	>
	Now that we’ve gotten the prerequisites out of the way, let’s get started. If you turn dark mode on, it will automatically be applied to all system UI elements and all Apple apps.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-134"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-132">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-133'
	>
	Install your application on a device running iOS 13, and you’ll quickly see that it falls into one of the following categories.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-137"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="lists" data-id="es-135">
	<ul	class='typography typography--size-16-text-roman js-typography lists__typography'
	data-id='es-136'
	>
	<li>App is ready for dark mode on day one. Kudos to you, you can kick back and enjoy the fruits of your labor.</li><li>App is a Frankenstein-like mix of light and dark modes. Yikes…</li><li>App does not support dark mode at all. Uh-oh!</li></ul></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-140"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-138">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-139'
	>
	But even if your app falls in the bottom two categories, don’t worry. You will learn how to leverage <strong>trait collections, dynamic colors and dynamic images</strong> in order to successfully transform your application into a versatile theming champion.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-143"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-141">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-142'
	>
	The scope of the work on your plate depends on the size of the app, the amount of custom elements used, and your project structure. However, the adoption steps will mostly remain the same. Let’s check them out.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-146"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-144">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-145'
	>
	1. Understanding trait collection</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-149"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-147">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-148'
	>
	It’s worth noting that <em>traitCollection</em> property was introduced over 5 years ago in iOS 8, as a part of the <em>UITraitEnvironment</em> protocol adopted by <em>UIScreen</em>, <em>UIWindow</em>, <em>UIViewController</em>, <em>UIPresentationController</em> and <em>UIView</em>.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-152"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-150">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-151'
	>
	It can be used to provide information about the iOS interface environment to your apps such as device type, device size class and display scale, but with iOS 13, we get a new property–<strong><em>userInterfaceStyle</em></strong>, which is used to determine the view’s appearance style.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-154"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-swift github-light" data-language="swift" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token">enum UIUserInterfaceStyle</span><span class="token">:</span><span class="token"> </span><span class="token" style="color: #6f42c1;">Int </span><span class="token">{</span><span class="token">
</span></span><span class="line"><span class="token">   </span><span class="token" style="color: #d73a49;">case</span><span class="token"> </span><span class="token">unspecified
</span></span><span class="line"><span class="token">   </span><span class="token" style="color: #d73a49;">case</span><span class="token"> </span><span class="token">light
</span></span><span class="line"><span class="token">   </span><span class="token" style="color: #d73a49;">case</span><span class="token"> </span><span class="token">dark
</span></span><span class="line"><span class="token">}</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-157"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-155">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-156'
	>
	Furthermore, <em>.unspecified</em> case is used to say that the object will inherit its style from its superview (or the system in case of a UIScreen), and <em>.light</em> and <em>.dark</em> styles are pretty self-explanatory.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-160"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-158">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-159'
	>
	This <em>traitCollection</em> information is passed through the interface hierarchy, as can be seen here:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-163"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-161"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-stretch" data-id="es-162">
	<picture class="image__picture block-media__image-picture">
												<img
					src="https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-2.webp"
					class="image__img block-media__image-img"
					alt=""
										height="600"
															width="900"
										loading="lazy"
					 />
					</picture>

			<figcaption class="image__figcaption block-media__image-figcaption">
			iOS 13 trait collection UIKit flow		</figcaption>
	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-166"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-164">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-165'
	>
	<em>UIScreen</em> gets the <em>userInterfaceStyle</em> property from the system and passes it onto the window scene, which propagates it to the window etc., etc. You get the idea.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-169"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-167">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-168'
	>
	This propagation means that the theme which should be used is not being read from the system on each hierarchical level, which allows us to <strong>override system appearance mode whenever we choose</strong>. For example, we can define a different interface style for just one view controller inside our app, and that style is then passed onto each of its child views, while unrelated views remain unaffected.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-172"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-170"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-stretch" data-id="es-171">
	<picture class="image__picture block-media__image-picture">
												<img
					src="https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-3.webp"
					class="image__img block-media__image-img"
					alt=""
										height="600"
															width="900"
										loading="lazy"
					 />
					</picture>

			<figcaption class="image__figcaption block-media__image-figcaption">
			iOS 13 override system appearance		</figcaption>
	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-175"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-173">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-174'
	>
	With iOS 13, <em>UIView</em>, <em>UIViewController</em>, and <em>UIWindow</em> have gained a new <strong><em>overrideUserInterfaceStyle</em></strong> property that lets us override the system appearance:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-177"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-swift github-light" data-language="swift" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #6a737d;">//</span><span class="token" style="color: #6a737d;"> Always light.</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> lightView </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token">UIView(</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">lightView.</span><span class="token">overrideUserInterfaceStyle</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> .</span><span class="token">light</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span><span class="line"><span class="token" style="color: #6a737d;">//</span><span class="token" style="color: #6a737d;"> Always dark.</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> darkView </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token">UIView(</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">darkView.</span><span class="token">overrideUserInterfaceStyle</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> .</span><span class="token">dark</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span><span class="line"><span class="token" style="color: #6a737d;">//</span><span class="token" style="color: #6a737d;"> Follows the appearance of its superview.</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> view </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token">UIView(</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">view.</span><span class="token">overrideUserInterfaceStyle</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> .</span><span class="token">unspecified</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-180"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-178">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-179'
	>
	This will get applied to the view at question, but also to all its subviews, so be careful when doing so and make sure it’s what you really want.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-183"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-181">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-182'
	>
	2. Dynamic colors</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-186"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-184">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-185'
	>
	Until now, both images and colors were static, which meant that they were always the same, independent of the environment. For example, if we added our own theming before, we would have to specify x different colors or images, with x being the number of themes we support.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-189"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-187">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-188'
	>
	Let’s see what has changed here.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-192"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-190">
	<h3	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-191'
	>
	Dynamic system colors</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-195"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-193">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-194'
	>
	Starting from iOS 13, <strong>UIColors can be dynamic</strong>, which means they contain one set of RGB values for light mode, and another for dark.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-198"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-196">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-197'
	>
	Whenever users change the system appearance, the <em>UIScreen</em> trait collection is changed, and the UI objects in the hierarchy are notified. If any view in the hierarchy contains elements which are using dynamic colors, such as labels or buttons, everything will automatically update to the appropriate color instantaneously, without us doing any work.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-201"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-199"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-stretch" data-id="es-200">
	<picture class="image__picture block-media__image-picture">
												<img
					src="https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-4.webp"
					class="image__img block-media__image-img"
					alt=""
										height="374"
															width="1103"
										loading="lazy"
					 />
					</picture>

			<figcaption class="image__figcaption block-media__image-figcaption">
			iOS 13 dynamic system colors		</figcaption>
	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-204"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-202">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-203'
	>
	As you can see from the picture above, contrary to the old static colors, system colors are slightly different for each mode, sporting a shade specifically made to look better on light or dark mode, respectively.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-207"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-205">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-206'
	>
	Same as with the static colors before, these can be easily selected from the storyboard/xib:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-210"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-208"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-auto" data-id="es-209">
	<picture class="image__picture block-media__image-picture">
												<img
					src="https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-5.webp"
					class="image__img block-media__image-img"
					alt=""
										height="681"
															width="315"
										loading="lazy"
					 />
					</picture>

			<figcaption class="image__figcaption block-media__image-figcaption">
			iOS 13 system colors in the storyboard		</figcaption>
	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-213"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-211">
	<h3	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-212'
	>
	Dynamic semantic colors</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-216"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-214">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-215'
	>
	What makes semantic colors different from regular ones? Naming convention based on purpose. Instead of telling us what color they’re representing, these colors are named with their use in mind.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-219"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-217">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-218'
	>
	Previous Xcode versions offered two static colors which were semantically named – <em>.lightText</em> and <em>.darkText</em>. Since they are static, they don’t play nicely with the dark mode. Lucky for us, Xcode 11 provides us with a full new suite of semantic colors such as <em>UIColor.label</em>, <em>UIColor.secondaryLabel</em>, <em>UIColor.headline</em> and many others which do!</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-222"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-220">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-221'
	>
	The most important take here is that using them ensures your app’s appearance will look familiar to the rest of the system. <em>UIColor.label</em> will look the same in all system apps, and using it in your app as well will <strong>make it feel native</strong>, which is always the best experience for the user.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-225"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-223">
	<h3	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-224'
	>
	Asset catalog dynamic colors</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-228"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-226">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-227'
	>
	Asset catalog provides us with an option to create a different color set, which can later be used in both code and storyboards/xibs. When you create a new color set, choose the attributes inspector and in the appearance section select <em>“Any, Light, Dark”</em> and add appropriate colors for all styles.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-231"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-229"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-auto" data-id="es-230">
	<picture class="image__picture block-media__image-picture">
								
			<source
				srcset=https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-6-1400x210.webp				media='(max-width: 699px)'
				type=image/webp								height="210"
												width="1400"
				 />
												<img
					src="https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-6.webp"
					class="image__img block-media__image-img"
					alt=""
										height="240"
															width="1600"
										loading="lazy"
					 />
					</picture>

			<figcaption class="image__figcaption block-media__image-figcaption">
			iOS 13 custom dynamic image		</figcaption>
	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-236"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="blockquote block-blockquote__blockquote" data-id="es-232">
	
	<div class="blockquote__content">
		<i
	class="icon blockquote__icon icon--size-16 icon--scale-100"
	 aria-hidden='true' data-name='blockquote-24' data-id='es-233'>
	<svg fill='none' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path clip-rule='evenodd' d='m12 24c6.6274 0 12-5.3726 12-12 0-2.79685-.9568-5.37021-2.561-7.41062-.581.22951-1.0832.60583-1.5069 1.12898-.5132.60844-.7698 1.41969-.7698 2.43375v.07605h2.5789v5.59004h-5.6197v-5.01962c0-1.11547.154-2.06616.4619-2.85205.3336-.81125.757-1.48307 1.2702-2.01545.528-.52161 1.1175-.92155 1.7687-1.1998-2.0728-1.70651-4.7279-2.73128-7.6223-2.73128-6.62742 0-12 5.37258-12 12 0 6.6274 5.37258 12 12 12zm-3.53811-18.05347c-.30793.78589-.46189 1.73658-.46189 2.85205v5.01962h5.6197v-5.59004h-2.5789v-.07605c0-1.01406.2566-1.82531.7698-2.43375.5389-.63379 1.1804-1.05209 1.9245-1.2549v-2.28164c-.7441.07605-1.4626.25351-2.1555.53238-.6928.27887-1.3086.68449-1.84752 1.21688-.51321.53238-.9366 1.2042-1.27019 2.01545z' fill='currentColor' fill-rule='evenodd'/></svg></i><p	class='typography typography--size-36-text js-typography blockquote__quote'
	data-id='es-234'
	>
	Note that this approach will not work in iOS 10 since it doesn’t support color declarations in the asset catalog.</p>
		<div class="blockquote__caption-wrap">
					</div>
	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-239"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-237">
	<h3	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-238'
	>
	Code</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-242"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-240">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-241'
	>
	If that disclaimer made you think <em>“Oh sh**, I still support iOS 10, what now?”</em>, no worries.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-245"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-243">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-244'
	>
	It’s also possible to create dynamic colors in code. You can initialize UIColor via <em>init(dynamicProvider:)</em> and return the corresponding colors depending on the current trait collection.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-247"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-swift github-light" data-language="swift" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> myDynamicColor </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token">UIColor</span><span class="token"> </span><span class="token">{</span><span class="token"> </span><span class="token">(</span><span class="token">traitCollection:</span><span class="token"> UITraitCollection</span><span class="token">)</span><span class="token"> </span><span class="token" style="color: #d73a49;">-&gt;</span><span class="token"> UIColor </span><span class="token" style="color: #d73a49;">in</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">switch</span><span class="token"> traitCollection.userInterfaceStyle </span><span class="token">{</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">case</span><span class="token"> .</span><span class="token">unspecified</span><span class="token">, .</span><span class="token">light</span><span class="token" style="color: #d73a49;">:</span><span class="token"> </span><span class="token" style="color: #d73a49;">return</span><span class="token"> </span><span class="token">UIColor(</span><span class="token">red:</span><span class="token"> </span><span class="token" style="color: #005cc5;">220</span><span class="token">, </span><span class="token">green:</span><span class="token"> </span><span class="token" style="color: #005cc5;">220</span><span class="token">, </span><span class="token">blue:</span><span class="token"> </span><span class="token" style="color: #005cc5;">220</span><span class="token">, </span><span class="token">alpha:</span><span class="token"> </span><span class="token" style="color: #005cc5;">1.0</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">case</span><span class="token"> .</span><span class="token">dark</span><span class="token" style="color: #d73a49;">:</span><span class="token"> </span><span class="token" style="color: #d73a49;">return</span><span class="token"> </span><span class="token">UIColor(</span><span class="token">red:</span><span class="token"> </span><span class="token" style="color: #005cc5;">0</span><span class="token">, </span><span class="token">green:</span><span class="token"> </span><span class="token" style="color: #005cc5;">0</span><span class="token">, </span><span class="token">blue:</span><span class="token"> </span><span class="token" style="color: #005cc5;">0</span><span class="token">, </span><span class="token">alpha:</span><span class="token"> </span><span class="token" style="color: #005cc5;">1.0</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token">}</span><span class="token">                           
</span></span><span class="line"><span class="token">}</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-250"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-248">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-249'
	>
	One thing to note here is that if you’re working with CALayers, they do not play nicely with dynamic colors since they are not a part of UIKit.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-253"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-251">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-252'
	>
	However, there is a neat way to get precisely the colors we need. Apple has also provided us with a function we can use to resolve colors for the current trait collection aptly named <em>resolvedColor(with:)</em>, as you can see below.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-255"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-swift github-light" data-language="swift" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> resolvedColor </span><span class="token" style="color: #d73a49;">=</span><span class="token"> UIColor.</span><span class="token">label</span><span class="token">.</span><span class="token">resolvedColor(</span><span class="token">with:</span><span class="token"> traitCollection</span><span class="token">)</span><span class="token"> 
</span></span><span class="line"><span class="token">layer.</span><span class="token">borderColor</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> resolvedColor.</span><span class="token">cgColor</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-258"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-256">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-257'
	>
	One more thing to consider and keep in mind regarding CALayer: since it’s not a part of UIKit, it also will not respond to any appearance changes. This is something you need to take care of manually, by updating its style through a callback or an observable (if you’re feeling reactive).</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-261"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-259">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-260'
	>
	3. Dynamic images</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-264"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-262">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-263'
	>
	In iOS 13, images, just like color sets, can also be dynamic. There are multiple ways to achieve this, so let’s take a look at the different options at our disposal.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-267"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-265">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-266'
	>
	Note that not all images will need to be dark-mode compliant. For example, if you allow user-imported images or color profiles, those will need to remain as they are regardless of the currently set appearance, so there’s no need to adjust them on the fly.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-270"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-268">
	<h3	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-269'
	>
	SF Symbols</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-273"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-271">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-272'
	>
	SF Symbols are a huge collection of over 1,500 consistent, highly configurable symbols you can use in your app that Apple has introduced during this year’s WWDC. They are <strong>fully integrated in the iOS 13 SDK and will automatically be available on every device that is running it</strong>, which means you don’t need to increase your app size by adding additional images and icons.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-276"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-274">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-275'
	>
	Another thing that really makes them shine is the automatic adaption to light/dark modes that comes out-of-the-box. In the image below, you can see just how versatile they really are, allowing you to adapt them to whichever style, weight or scale you may need.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-279"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-277"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-stretch" data-id="es-278">
	<picture class="image__picture block-media__image-picture">
								
			<source
				srcset=https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-7-1400x529.webp				media='(max-width: 699px)'
				type=image/webp								height="529"
												width="1400"
				 />
												<img
					src="https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-7.webp"
					class="image__img block-media__image-img"
					alt=""
										height="569"
															width="1505"
										loading="lazy"
					 />
					</picture>

			<figcaption class="image__figcaption block-media__image-figcaption">
			SF Symbols adapting to font		</figcaption>
	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-282"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-280">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-281'
	>
	You can use SF Symbols in two ways in your apps, through storyboards/xibs or by creating them in code.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-285"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-283"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-stretch" data-id="es-284">
	<picture class="image__picture block-media__image-picture">
								
			<source
				srcset=https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-8-1400x822.webp				media='(max-width: 699px)'
				type=image/webp								height="822"
												width="1400"
				 />
												<img
					src="https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-8.webp"
					class="image__img block-media__image-img"
					alt=""
										height="939"
															width="1600"
										loading="lazy"
					 />
					</picture>

			<figcaption class="image__figcaption block-media__image-figcaption">
			Using SF Symbols in storyboard		</figcaption>
	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-288"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-286">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-287'
	>
	To use SF Symbols through the interface builder, all you need to do is add an image view, type the symbol name and you’re done. Next to the image name you’ll be able to se the “System” text telling you that you are using an SF Symbol; images you import through the Assets will not have that text.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-291"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-289">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-290'
	>
	If you prefer setting up your images through code, you can also use symbols there by using the new UIImage initializer which takes a system name, like so:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-293"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-swift github-light" data-language="swift" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> image </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token">UIImage(</span><span class="token">systemName:</span><span class="token"> </span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">cloud</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-296"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-294">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-295'
	>
	Since there are a lot of symbols available here and scrolling through them in Xcode can quickly become tiring, Apple has created an official <a href="https://developer.apple.com/design/downloads/SF-Symbols.dmg">SF Symbols app</a> that can be used for easier reference or a quick look at all the available symbols.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-299"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-297">
	<h3	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-298'
	>
	Custom images</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-302"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-300">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-301'
	>
	For your custom images, you can define different image assets for both light and dark modes, and it can be done directly from the asset catalog, just like with custom colors. Just set their appearance in the right pane, drop a new image for each appearance and you’re done.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-305"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-303"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-stretch" data-id="es-304">
	<picture class="image__picture block-media__image-picture">
												<img
					src="https://infinum.com/uploads/2019/09/how-to-prepare-your-app-for-dark-mode-in-iOS-13-9.webp"
					class="image__img block-media__image-img"
					alt=""
										height="600"
															width="900"
										loading="lazy"
					 />
					</picture>

			<figcaption class="image__figcaption block-media__image-figcaption">
			Custom dynamic images in Asset catalog		</figcaption>
	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-308"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-306">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-307'
	>
	If, for some reason, you want to resolve the image and determine which one will be used, you can do that easily by resolving images by using the current trait collection:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-310"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-swift github-light" data-language="swift" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> image </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token">UIImage(</span><span class="token">named:</span><span class="token"> </span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">image</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> asset </span><span class="token" style="color: #d73a49;">=</span><span class="token"> image</span><span class="token" style="color: #d73a49;">?</span><span class="token">.</span><span class="token">imageAsset</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> resolvedImage </span><span class="token" style="color: #d73a49;">=</span><span class="token"> asset</span><span class="token" style="color: #d73a49;">?</span><span class="token">.</span><span class="token" style="color: #005cc5;">image</span><span class="token">(</span><span class="token">with:</span><span class="token"> traitCollection</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-313"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-311">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-312'
	>
	4. Attributed text</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-316"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-314">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-315'
	>
	If you’ve ever used attributed text in your apps, you probably know that unless you specify the <em>foregroundColor</em> property, it will be automatically set to <em>.black</em>.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-319"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-317">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-318'
	>
	That was probably fine before if you weren’t using a black background, but with iOS 13, it will not work as expected when using the dark appearance–black text on a black background is a big no-no.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-322"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-320">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-321'
	>
	That’s where things like semantic colors come into play, as you can see below.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-324"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-swift github-light" data-language="swift" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #d73a49;">let</span><span class="token"> attributedText </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">Hello dark mode</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span><span class="line"><span class="token">let attributes:</span><span class="token"> </span><span class="token">[</span><span class="token">NSAttributedString.</span><span class="token" style="color: #005cc5;">Key</span><span class="token">:</span><span class="token"> </span><span class="token" style="color: #005cc5;">AnyObject</span><span class="token">]</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> [
</span></span><span class="line"><span class="token">    .</span><span class="token">font</span><span class="token" style="color: #d73a49;">:</span><span class="token"> UIFont.</span><span class="token">preferredFont(</span><span class="token">forTextStyle:</span><span class="token"> .</span><span class="token">body</span><span class="token">)</span><span class="token">,
</span></span><span class="line"><span class="token">    .</span><span class="token">foregroundColor</span><span class="token" style="color: #d73a49;">:</span><span class="token"> .</span><span class="token">label</span><span class="token">
</span></span><span class="line"><span class="token">]
</span></span><span class="line"><span class="token">
</span></span><span class="line"><span class="token">attributedText.</span><span class="token">draw(</span><span class="token">at:</span><span class="token"> .</span><span class="token">zero</span><span class="token">, </span><span class="token">withAttributes:</span><span class="token"> attributes</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-327"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-325">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-326'
	>
	5. Responding to appearance changes</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-330"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-328">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-329'
	>
	Whenever users change their appearance styles, several methods get called. You can leverage this by putting any additional UI logic which depends on the current appearance into these methods:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-333"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="lists" data-id="es-331">
	<ul	class='typography typography--size-16-text-roman js-typography lists__typography'
	data-id='es-332'
	>
	<li>UIViewController – <em>viewWillLayoutSubviews()</em>,</li><li>UIPresentationController – <em>containerViewWillLayoutSubviews()</em>,</li><li>UIView – <em>layoutSubviews()</em> and <em>tintColorDidChange()</em>.</li></ul></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-336"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-334">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-335'
	>
	In addition, since all those objects conform to the <em>UITraitEnviromentprotocol</em>, <em>traitCollectionDidChange()</em> will also get called.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-339"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-337">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-338'
	>
	To simplify–if you’ve been initializing your colors/images in the <em>init</em> and <em>viewDidLoadmethods</em>, move that logic into the <em>layoutSubviews()</em> and <em>viewDidLayoutSubiews()</em> methods and you should be good to go. Any additional logic you have regarding the appearance can go into the <em>traitCollectionDidChange()</em> method, which will also get called when the appearance updates.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-342"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-340">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-341'
	>
	But… What if I don’t want to support it?</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-345"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-343">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-344'
	>
	Having read all of the above, this question may have popped into your head, and it’s a perfectly valid dilemma.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-348"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-346">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-347'
	>
	There are several reasons why you wouldn’t want to add dark mode support: perhaps there’s no time to implement it properly or your brand guidelines are centered around light themes, to name only a few. Luckily for you, it’s really easy to disable dark mode and forget all about it.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-351"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-349">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-350'
	>
	There are three main ways to do this:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-354"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="lists" data-id="es-352">
	<ul	class='typography typography--size-16-text-roman js-typography lists__typography'
	data-id='es-353'
	>
	<li>set <em>UIUserInterfaceStyle</em> to <em>Light</em> in your info.plist,</li><li>override the appearance in the <em>UIScreen</em>,</li><li>keep shipping your app with older Xcode versions.</li></ul></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-357"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-355">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-356'
	>
	For partial support, just override interface styles on screens where you don’t want to support dark mode by using the code shown in the first heading, <strong>1. Understanding the trait collection</strong>.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-360"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-358">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-359'
	>
	However, keep in mind that <strong>Apple really wants you to fully support dark mode</strong>, and their quote from WWDC should really drive that point home.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-365"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="blockquote block-blockquote__blockquote" data-id="es-361">
	
	<div class="blockquote__content">
		<i
	class="icon blockquote__icon icon--size-16 icon--scale-100"
	 aria-hidden='true' data-name='blockquote-24' data-id='es-362'>
	<svg fill='none' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path clip-rule='evenodd' d='m12 24c6.6274 0 12-5.3726 12-12 0-2.79685-.9568-5.37021-2.561-7.41062-.581.22951-1.0832.60583-1.5069 1.12898-.5132.60844-.7698 1.41969-.7698 2.43375v.07605h2.5789v5.59004h-5.6197v-5.01962c0-1.11547.154-2.06616.4619-2.85205.3336-.81125.757-1.48307 1.2702-2.01545.528-.52161 1.1175-.92155 1.7687-1.1998-2.0728-1.70651-4.7279-2.73128-7.6223-2.73128-6.62742 0-12 5.37258-12 12 0 6.6274 5.37258 12 12 12zm-3.53811-18.05347c-.30793.78589-.46189 1.73658-.46189 2.85205v5.01962h5.6197v-5.59004h-2.5789v-.07605c0-1.01406.2566-1.82531.7698-2.43375.5389-.63379 1.1804-1.05209 1.9245-1.2549v-2.28164c-.7441.07605-1.4626.25351-2.1555.53238-.6928.27887-1.3086.68449-1.84752 1.21688-.51321.53238-.9366 1.2042-1.27019 2.01545z' fill='currentColor' fill-rule='evenodd'/></svg></i><p	class='typography typography--size-36-text js-typography blockquote__quote'
	data-id='es-363'
	>
	“You really don’t want to be that one light appearance that’s stuck in dark appearance.”.</p>
		<div class="blockquote__caption-wrap">
					</div>
	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-368"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-366">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-367'
	>
	In other words, not switching to dark mode will make you the black sheep… If that makes any sense.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-371"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-369">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-370'
	>
	The dark mode sees the light of day</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-374"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-372">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-373'
	>
	We’ve been eagerly anticipating dark mode on iOS ever since Apple released it on the Mac last year–and it’s finally here.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-377"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-375">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-376'
	>
	It appears to be a much-needed trigger which will encourage more iOS developers to look into app theming. By following the steps I’ve detailed in this post, you’ll be on course for perfecting dark mode in no time.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-380"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-378">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-379'
	>
	Go ahead, <a href="https://www.youtube.com/watch?v=O4irXQhgMqg">paint it black</a>. Happy theming!</p></div>	</div>
</div>
</div>		</div>
	</div><p>The post <a href="https://infinum.com/blog/how-to-prepare-your-app-for-dark-mode-in-ios-13/">How to Prepare Your App for Dark Mode in iOS 13</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</content:encoded>
			</item>
		
	</channel>
</rss>