<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Raynelle Alphonso on Medium]]></title>
        <description><![CDATA[Stories by Raynelle Alphonso on Medium]]></description>
        <link>https://medium.com/@raynelle.alphonso_45535?source=rss-715229d76f64------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2dX3YwMGnBgqF7s_</url>
            <title>Stories by Raynelle Alphonso on Medium</title>
            <link>https://medium.com/@raynelle.alphonso_45535?source=rss-715229d76f64------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 05:04:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raynelle.alphonso_45535/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SwiftUI in iOS 16]]></title>
            <link>https://medium.com/kinandcartacreated/swiftui-in-ios-16-42ecb601097e?source=rss-715229d76f64------2</link>
            <guid isPermaLink="false">https://medium.com/p/42ecb601097e</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios-16]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Raynelle Alphonso]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 14:18:23 GMT</pubDate>
            <atom:updated>2022-10-25T14:18:23.165Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6BSqhFs5rxUFSW7I9P2DBw.jpeg" /></figure><p>At WWDC22 Apple introduced a lot of cool new features. The ones that stood out to me were; the ability to add a more personal touch to the lock screen, Live Activities which allow you to stay up to date on what’s happening in real time, and Notifications which now appear at the bottom of the screen, and are more organised.</p><p>Today though, I will be focusing on the new updates to SwiftUI, which was one of the main topics of the conference.</p><p>In this article we will look specifically at some of the new Swift UI features for iOS 16. See list below:</p><ul><li><a href="#6fb1">Navigation Stack</a></li><li><a href="#e5fb">Table</a></li><li><a href="#b1a2">Grids</a></li><li><a href="#5000">BottomSheets</a></li><li><a href="#b042">MultidatePicker</a></li><li><a href="#c718">ShareLink</a></li><li><a href="#0bf9">Anylayout</a></li><li><a href="#e124">ViewThatFits Container</a></li><li><a href="#d5be">scrollDismissesKeyboard modifier</a></li><li><a href="#6e7b">SF Symbols</a></li><li><a href="#b86b">Text animation</a></li><li><a href="#08be">Swift Charts</a></li></ul><p>Looks like we have quite a bit to get through, so let’s get straight into it.</p><p><strong>Navigation Stack</strong></p><p>SwiftUI provides the new data-driven Navigation API. The old NavigationView has been deprecated. We now have the NavigationStack<strong> </strong>and<strong> </strong>the updatedNavigationLink<strong>.</strong></p><p>The NavigationLink type adds new data-driven capabilities. A new initializer allows you to create a link bound to some value.</p><p>Let’s look at an example: We have a struct Item with title and price.</p><p>The ContentView which will have our list of items, and the ProductDetailView which will show the details of that item when tapped.</p><p>In the ContenView we define an array of Items of type [Item]. It has 2 values in it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50a636eb4bacf54413bd812be6736d53/href">https://medium.com/media/50a636eb4bacf54413bd812be6736d53/href</a></iframe><p>The NavigationStack is the root of our view hierarchy. We then have a list of items and each item should navigate to the item details screen.</p><p>We are using the new value-based NavigationLink to take the user to the next screen. Notice how we associate every item on the list with a particular value. Here the value is our item object. (Line 9)</p><p>We then define a destination view (Next Screen) using the navigationDestination view modifier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*Xe1Q0bnfQaPnREmio8BXNw.gif" /></figure><p><strong>Table</strong></p><p>Up until iOS 16 we only had List which are used to enable scrolling through an extensive data set arranged in a <strong>single</strong> column.</p><p>iOS 16 and iPadOS 16 introduces Table. A table presents rows of data arranged in <strong>multiple</strong> columns.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/686fd6f045994c253046e04857a7a9d1/href">https://medium.com/media/686fd6f045994c253046e04857a7a9d1/href</a></iframe><p>iPad simulator:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*rIwUwTPcS3OOTH1Ee2AiGw.png" /></figure><p>Note that Table will not work as expected on iOS. If you try running the same code on iOS you will see only the first column. There is little more work to do on the iOS side.</p><p>iPhone:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*WbtqgVFR907WLncYKHg3Rw.png" /></figure><p>According to Apple:</p><p><em>macOS and iPadOS support SwiftUI tables. On iOS, and in other situations with a compact horizontal size class, tables don’t show headers and collapse all columns after the first. If you present a table on iOS, you can customize the table’s appearance by implementing compact-specific logic in the first column.</em></p><p>What this means is that we need to use the <a href="https://developer.apple.com/documentation/swiftui/environmentvalues/horizontalsizeclass">horizontalSizeClass</a> which tells us the value tells us about the amount of space available to your views in a given direction. This class can return a regular value meaning we have lots of space available, so for example iPad, or it can return compact<strong> </strong>value when the space is limited.</p><p>For iPhones, compact will be returned.</p><p>Let’s look at how we can implement this in the code snippet below.</p><p>In the first TableColumn (lines 19,20) we check if it’s a compact size , if so then in that TableColumn we load the TableRowView class which contains the givenName, familyName and emailAddress in a Horizontal stack.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d2d1dd58ed4eb7b1fea8cf54c18f7d9/href">https://medium.com/media/1d2d1dd58ed4eb7b1fea8cf54c18f7d9/href</a></iframe><p>The output will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*j4ofDB0WZPw3hvpl4Ud-dQ.png" /></figure><p><strong>Grids</strong></p><p>Grid view allows you to create a static grid of views, with control over what goes into each row and column. A Grid view arranges child views in rows and columns. And this table-like structure makes a layout that is hard to do in vertical and horizontal stacks become easier.</p><p>A Grid is populated with a GridRow and each GridRow represents each cell/column in a Grid view. Lets look at an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ebba3e8e35a92a8b377ddbe427b47db/href">https://medium.com/media/9ebba3e8e35a92a8b377ddbe427b47db/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*ZHMHjgM9HA0Svg9b3Pr9tw.png" /></figure><p>You might be wondering what’s the difference between doing it this way and using a HStack and VStack. Let’s take a look at the code for the HStack and VStack:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bcb0aeefdc9753995cdc690c2a7f8fc2/href">https://medium.com/media/bcb0aeefdc9753995cdc690c2a7f8fc2/href</a></iframe><p>You will get the below result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*HMH8VUw2Oz_sjwCrNbFQJQ.png" /></figure><p>The difference being that each cell/column of the HStack isn’t related to the other rows. A horizontal stack layout its components without considering other rows while a Grid handles row and column creation as a single operation. Which is why each column in a Grid will take the same space across the row. Grid width and height grow according to its child view.</p><p>There’s a lot you can do with this and definitely worth playing around.</p><p><strong>Bottom sheets</strong></p><p>The new presentationDetents() modifier allows you to create a sheet that can slide up from the bottom. And we can set how much of the screen we would want it to occupy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/071cfa575b2de9bbac6d6d5b77b3493b/href">https://medium.com/media/071cfa575b2de9bbac6d6d5b77b3493b/href</a></iframe><p>Here we set the presentationDetents to medium and large. This will allow the user to adjust the size of the sheet to medium i.e half screen and large i.e full screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*wj7XWxsXPfVXPj5-hxFIUQ.gif" /></figure><p>You can also provide a fraction as to how much of the screen the sheet should occupy like this: .presentationDetents([.fraction(0.15)]). In this case the sheet would take up 15% percent of the screen.</p><p><strong>MultiDatePicker</strong></p><p>Just as the name suggest , the MultiDatePicker now allows you to select multiple dates at once.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0139e02fb91868ef8bda74f726966cc/href">https://medium.com/media/b0139e02fb91868ef8bda74f726966cc/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*etdKHfMvGc47mkJv9wDhbw.gif" /></figure><p><strong>ShareLink</strong></p><p>We now have a new way of showing the share sheet through ShareLink. ShareLink takes in an item that can be a string, URL, basically anything that conforms to Transferable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f9022256e1d7c4d07981656b7ca86d9/href">https://medium.com/media/1f9022256e1d7c4d07981656b7ca86d9/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*dzoh6hM8XBm8rpTpTi14FQ.gif" /></figure><p><strong>AnyLayout</strong></p><p>This new struct will allow the user to switch between HStack and VStack based on the environment context.</p><p>Example if we wanted to align a group of images horizontally when we’re in a regular horizontal size class, or vertically otherwise.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ab232532242976a2b6e25c17d01487a/href">https://medium.com/media/9ab232532242976a2b6e25c17d01487a/href</a></iframe><p>When the phone is in portrait mode we should see the images displayed vertically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*id2M9wRZq6MkbcFhav0Udg.png" /></figure><p>And when we switch to landscape , we should see the images horizontally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*lzulDglqixfTCmIKYUI3wA.png" /></figure><p><strong>ViewThatFits Container</strong></p><p>This new container allows us to provide multiple views and the system will then automatically pick the first one which fits into available space. This is very useful when building adaptive layouts.</p><p>Example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d99cbd1a5fc7b79ee08bef0c2186b658/href">https://medium.com/media/d99cbd1a5fc7b79ee08bef0c2186b658/href</a></iframe><p>Here we have an array of textValues. The first text is a short one and the next text is a very long one.</p><p>What we want to achieve is for the short text we want to show the text as it is, but for the longer text values we want to show a more button at the side of it which can be used to show the whole text.</p><p>In the code above, the ViewThatFits container has a Text View and a HStack with a Text View and More Button.</p><p>For the first item, the ViewThatFits container checks if the text in the Text view fits into its parent container and since it does , it stops there.</p><p>For the second item, the text does not fit into the first Text View , so ViewThatFits uses the next view i.e the HStack with the Text and Button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*pVbtPJlH2Ylgcyp2E3-edA.png" /></figure><p><strong>scrollDismissesKeyboard()</strong></p><p>This modifier allows the user to control how the keyboard should dismiss when the user scrolls around.</p><p>This modifier takes in 4 values:</p><p>.automatic — lets the system decide what’s the best thing to do based on the context of the scroll.</p><p>.immediately — dismisses the keyboards as soon as the scroll happens.</p><p>.interactively — dismiss keyboard inline with the user’s gesture</p><p>.never — the keyboard will always be present.</p><p>Example of the interactively value:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b3f2d7a2f40c7611629755d91d51832/href">https://medium.com/media/1b3f2d7a2f40c7611629755d91d51832/href</a></iframe><p>The result: You can see that the keyboard is being dismissed as the user scrolls down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*1B042TEmubtE2Fx-6oiu_A.gif" /></figure><p><strong>SF Symbols</strong></p><p>More than 700 new symbols have been added in SF Symbols 4. This will help our apps look more native. One of the really cool features this year for SF symbols is the variable color.</p><p>This means that colors can now be dynamically applied to system and custom symbols using a percentage value to convey strength or progress over time.</p><p>Let’s look at an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc71e788e6309929467c079d7d58db4a/href">https://medium.com/media/dc71e788e6309929467c079d7d58db4a/href</a></iframe><p>What we have done here is the value assigned to the icons can change as we slide the slider. The value is binded to the slider. This will cause the images to reflect color change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*wbGpdZcySNpIuGx5vMEeDw.gif" /></figure><p><strong>Text animation</strong></p><p>You can animate all text characteristics by using just withAnimation.</p><p>Let’s look at an example:</p><p>Here we are switching between 2 font weights and colors. Adding the withAnimation will add a nice animation between the 2 states.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40f71214c8a80a6e9cc3ddad29f75f0a/href">https://medium.com/media/40f71214c8a80a6e9cc3ddad29f75f0a/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*-E0Z7yyzO8U2Hfj9svDN8Q.gif" /></figure><p><strong>Swift Charts</strong></p><p>Converting your data into line charts, bar charts and scatter plots has never been easier.</p><p>The new swift UI charts allows you to create charts with very little code. When you create a chart using this framework, it automatically generates scales and axes that fit your data.</p><p>Example:</p><p>The first thing you need to do is define your datasource. Also make sure you import Charts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76f014987b027c9c46f7463890777fbf/href">https://medium.com/media/76f014987b027c9c46f7463890777fbf/href</a></iframe><p>Here we have a struct of an energy bill.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a67249ea7ffdad8e0fd8499b9822a1f/href">https://medium.com/media/7a67249ea7ffdad8e0fd8499b9822a1f/href</a></iframe><p>Next we import Charts and create an array of energy bills and then in the body we create a Chart with individual BarMark giving it a x for month, and y value for the amount. The results looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*_dzNkurTrEJi2nlsMM_dMw.png" /></figure><p>You can change the BarMark to PointMark and that will give you a point on the chart.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0861e8ee273aad7a851cd28d9ecf3d35/href">https://medium.com/media/0861e8ee273aad7a851cd28d9ecf3d35/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*Qpz8kLISCHBgFyF5CFq4Cg.png" /></figure><p><strong>Conclusion</strong></p><p>It’s nice to see there’s so much being done on the SwiftUI side and there is still so much more to learn from this year’s iteration.</p><p>During Platforms State of the Union<em> </em>talks this year Apple said “<a href="https://developer.apple.com/videos/play/wwdc2022-112/?time=1759">the best way to build an app is with Swift and SwiftUI.</a>”</p><p>Which of these new additions did you like the most?</p><p>Thank you so much for taking the time to read and I really hope you enjoyed the article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42ecb601097e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kinandcartacreated/swiftui-in-ios-16-42ecb601097e">SwiftUI in iOS 16</a> was originally published in <a href="https://medium.com/kinandcartacreated">Kin + Carta Created</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SwiftUI Changes in iOS 14]]></title>
            <link>https://medium.com/kinandcartacreated/swiftui-changes-in-ios-14-57ad348376ee?source=rss-715229d76f64------2</link>
            <guid isPermaLink="false">https://medium.com/p/57ad348376ee</guid>
            <dc:creator><![CDATA[Raynelle Alphonso]]></dc:creator>
            <pubDate>Wed, 19 Aug 2020 19:39:06 GMT</pubDate>
            <atom:updated>2020-08-24T09:37:35.086Z</atom:updated>
            <content:encoded><![CDATA[<p>Apple announced many new features and cool things this year in its WWDC conference. Amongst them, some new additions to SwiftUI and the fact that Widgets must now be written with SwiftUI gave us all more reason to learn and start developing with it.</p><p>In this post, I’m going to give an overview of SwiftUI, explain it’s advantages as well as cover some of the latest additions to it.</p><h3>What is SwiftUI</h3><p>So back in Sept 2019 Apple released a new a toolkit/framework SwiftUI that would allow developers to create UI in a declarative way across all Apple platforms with the power of Swift.</p><p>Here are some benefits of SwiftUI. If you have worked with Flutter or React before, both use a declarative approach instead of an imperative one. So some of these benefits and the experience of working with SwiftUI should be similar.</p><ul><li>It’s easy to learn.</li><li>It has declarative syntax. i.e you just declare what the desired end result is and then the framework can then work out how to get to that result. It’s easily readable, less prone to errors and can be re-used.</li><li>It has live preview of each View that you create and you can see the results in real time. You don’t need to build the App every time.</li><li>No interface builder and no IBOutlets association. This makes it easier to manage code and your App won’t crash due to updating of IBOutlets with variables.</li></ul><p>Now to the fun part. Let’s look at each cool addition to SwiftUI in iOS 14. I have added screenshots of the code and simulator for each feature so it will make it easier to understand.</p><p>Let’s quickly scan through these then!</p><h3>Views</h3><p><strong>TextEditor</strong></p><p>We now have a TextEditor that supports multiple lines and it can be customised. i.e you can add custom fonts and colors to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*ncPujzEQF9tXmOZRbMZVRg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/0*_IMPSbwdulZe8AfK" /></figure><p><strong>ProgressViews</strong></p><p>SwiftUI now has a progressView which can be used to show a task’s progress. It can be a progress bar or a spinning indicator.</p><p><em>Spinning Progress View</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*FzK5KdGtlPPYI6iM3JQioQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*UOq8_V6TPmZIUDxmduVgXA.png" /></figure><p><em>Progress Bar</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*8no3AiXwyoSo5I85qvLZtA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*P_LjQrBIu6VG8svyNEfVyw.png" /></figure><p><strong>Maps</strong></p><p>SwiftUI now allows us to embed map views in our user interface. All you need to do is import MapKit and then define the region i.e the latitude and longitude and set it to our map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*UFVPr6VkDtGCVijqTCfGRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*UqY1LUsiA5lxiyYneUk2rA.png" /></figure><p><strong>Opening links</strong></p><p>You can now create tappable links that will launch safari.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*rnlod4b2INzvLcTHwHMJPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/0*saqvhJfzz6EMUW-x" /></figure><p><strong>Lazy VGrid and HGrid</strong></p><p>You can now make vertical and horizontal grids. And the content will be created as it comes into view. Hence the word Lazy</p><p>We can have 3 types of grid layouts:</p><p>Adaptive layout — here the grid will try to add as many items of the minimum size into each row in the grid based on the width of the grid.</p><p>Flexible layout — here you can specify the number of columns in the grid, and each of which takes equal spaces by default.</p><p>Fixed layout — here you can give a fixed width to a column</p><p>So let’s look at examples of each:</p><p>What we have done here is, we have created 500 items and we will display them based on the different layouts</p><p><em>Adaptive layout: In our code below the system will try and fit in as many columns and while keeping the grid item at a minimum size of 80.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*jmVUbzpt5bMtDkA3Jfhi3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*EtdS99f5tjDl3cPNf8GAJw.png" /></figure><p><em>Flexible layout: here we have 2 flexible items, which means that the system will distribute the grid into 2 equal columns</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*17vHtP1aKj71MJYOExQbXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*OzPgRutjcfoRD6nohyM_Aw.png" /></figure><p><em>Fixed layout: In our code below we have fixed griditems at 60 and 150. So the system will create 2 columns of fixed widths 50 and 150</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*b8c9jX2rteppkPLGzzSjMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*v0ylTOmkdJ3Fua8OC9pdiA.png" /></figure><p>You can take all of this one step further and combine the different layouts and your grid will react to that accordingly.</p><p><strong>Swiping through views with TabView</strong></p><p>Swiping through different views can now be done in SwiftUI.</p><p>In the code below we are on the main swift file and we have wrapped our views (FirstContentView, SecondContentView and ThirdContentView) around a Tabview.</p><p>And we have given it a tabViewStyle of PageTabViewStyle. And that’s it. We now have a swipe-able paging view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*wEPh7tjpUxmTMoY96J5qeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*lItGRzfYWxwgDShec9677g.gif" /></figure><p><strong>DatePicker</strong></p><p>This DatePicker now has a nice calendarView for iOS 14. Very easy to implement and customize.</p><p>In the code below, the in:…Date() specifies the date range up to the current date. Therefore you see in the simulator the dates after the 15th of Aug <em>(which was the current date at the time)</em> are grayed out. Similarly if you were to enter in:Date()…, this would do the opposite i.e disable the dates before the current date.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*hdpXVE8rOkZHLa07iSJJBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*5dE1nEoIs3uzNq5d" /></figure><p><strong>ColorPicker</strong></p><p>You can now pick colors from a native color picker. To use it you need to create a color property that can be changed using a @State. And then initialize the ColorPicker in your View.</p><p>Like this</p><pre>ColorPicker(“Choose color”, selection: $bgColor)</pre><p>Where<em> </em>bgColor<em> </em>is the binding state value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*7hyMq560V8jcqEobELsX6w.gif" /></figure><p>Apart from these New Views that have been added. We also have new modifiers and property wrappers . Let’s go through these in brief.</p><h3>Modifiers</h3><p><strong>onChange()</strong></p><p>You can add this modifier to any view to detect changes in the program. In our code below we have added the onChange() modifier to our TextField with the binding variable text<em>.</em> You can see in the simulator that as the user types into the textfield the updated value for $text is printed in the debug console log.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*H2C-qEyehKQWwo66WgWmug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/0*QwBc7E3-vM9del-C" /></figure><p><strong>redacted()</strong></p><p>This modifier generates a placeholder for a view and grays out your content with the purpose of hiding it. In the code below we have added the redacted modifier to the dummy national insurance number. You can see in the simulator that the number is grayed out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*hg62erLQ8mzTGXp9qD3B9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*V0ovnKH1Uq0xStRHl3Vupg.png" /></figure><p><strong>scrollTo()</strong></p><p>If you want to scroll to a particular location of a scrollView, this is now possible by adding a scrollViewReader that has a scrollTo() method which can move to any location in the scrollview by providing its anchor and id of the item within the scrollview.</p><p>In the code below we have added 20 Text items through a loop in the scrollView. Each text item has a frame and Id. The Id will be used to scroll to that particular item. On tap of the button with value.scrollTo(9, anchor: .top) we are scrolling to the 9th item in the scrollView. The anchor:.top will make sure the item is scrolled to the top of the view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*lgb8PAdClfkWTldlomrRVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*urTt5OVARCnCCUD6" /></figure><p><strong>appStoreOverlay()</strong></p><p>This can be used to recommend other apps on the App Store. It will need a state to check if the App Store overlay is active or not, and a SKOverlay.AppConfiguration will show the recommended App. we will have to pass the app identifier to SKOverlay.AppConfiguration.</p><h3>Property Wrappers</h3><p><strong>StateObject</strong></p><p>We have previously used ObservedObject to create a reference type inside your views and use it. However the drawback of using the ObservedObject is that ObservedObject can accidentally release the object it was storing.</p><p>In iOS 14 we now have<strong> </strong>StateObject that will<strong> </strong>be<strong> </strong>used to create a reference type inside your views and makes sure it is not released and stays alive for use in that view and other views that use it.</p><p><strong>ScaledMetric</strong></p><p>This property wrapper can be used to automatically scale according to the user’s dynamic settings.</p><p><strong>AppStorage</strong></p><p>This can be used for reading and writing values to UserDefaults.</p><h3>Conclusion</h3><p>It’s worth noting that it would be nice to see these features like SearchController, SearchBar, ImagePickerController, RefreshControl that aren’t available yet in SwiftUI get added as well.</p><p>However I would like to say that SwiftUI in iOS 14 has a lot to offer. And definitely worth diving into it.</p><p>Hope this article has helped get an overview of some of the new features we have so far. Have fun playing with SwiftUI and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57ad348376ee" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kinandcartacreated/swiftui-changes-in-ios-14-57ad348376ee">SwiftUI Changes in iOS 14</a> was originally published in <a href="https://medium.com/kinandcartacreated">Kin + Carta Created</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>