Note: This tutorial is also available in video form on YouTube.
In this tutorial, we’re going to learn how to use MapKit in SwiftUI to find a route and directions between two places. With iOS 14, Apple introduced MapKit for SwiftUI; however, it still lacks many features that are only available in UIKit.
We’re going to solve this issue by creating a UIViewRepresentable
that will act as a wrapper around a UIKit
MKMapView
. This will allow us to implement MKMapViewDelegate
functions that we can use to draw a route overlay on the map.
Note: This tutorial is also available in video form on YouTube
With SwiftUI, Apple introduced List
to be able to display a collection of content. Previously, with UIKit
, one had to use a UITableView
and implement delegate and data source methods (e.g. didSelectRowAt
) to provide row content and navigate between views when a row is selected.
Since SwiftUI is declarative, the content of each row is provided at the time of declaring the List
. In addition, we can now use a NavigationLink
to handle navigation between views.
We will be building a simple app that displays a list of…
Creating a to-dos app for iOS
Note: This tutorial is also available in video form on YouTube.
In this tutorial, we’re going to build an app where you can keep track of your to-dos and delete them when they’re done. We’re also going to learn how to save these to-dos in a database for iOS called UserDefaults
. This will help us ensure that your to-dos are saved even when closing the app.
This is what our app will look like:
Recently, I read James Clear’s popular book Atomic Habits. As I was reading, I took some notes on things I thought I should remember to apply in my everyday life. Building good habits—and losing bad ones—can be difficult, but simple techniques, like the ones presented in Atomic Habits, can help ease these processes. Below, I share 4 of my key takeaways from reading this amazing book.
It is very easy to lose motivation when we don’t obtain the results we want; sometimes we may feel as though we’ve put too much effort trying to achieve something, without actually seeing any…
Note: This tutorial is also available in video form on YouTube.
In a previous article, I showed you how to build an expandable button with Swift and UIKit. With SwiftUI gaining traction, I decided to share an updated article showing how we can implement this same functionality using SwiftUI.
Implementing custom views with SwiftUI is extremely simple, and we will leverage its power to build an expandable button that will look like the one below:
Note: This is the third and final part of my 3-part widget tutorial. Make sure to complete part 1 and part 2 before continuing with this article.
Note: You’ll need Xcode 12 Beta 2 or higher to follow this tutorial.
So far, we have created a simple list-based app that displays different emoji along with their names, and allows you to view details about a specific emoji by tapping on it. Furthermore, we created a widget for our app–which can be small, medium, or large–and will display an emoji that is updated randomly every hour.
Note: This is part 2 of a 3-part tutorial. Make sure to complete part 1 before continuing with this article. You can find part 3 here.
Widgets on iOS can support 3 different sizes: small, medium, and large. In part 1 of this tutorial, we only added support for small widgets. Now we will add a medium widget and a large widget as well.
Note: You’ll need Xcode 12 Beta 2 or higher to follow this tutorial.
Open up the Emojibook
project on Xcode and navigate to the Emojibook_Widget.swift
file. To support different widget sizes, all we have to do…
Note: This is part 1 of a 3-part tutorial. Find part 2 here, and part 3 here.
During WWDC 2020, Apple announced the introduction of app widgets for iOS (as well as iPadOS and MacOS). With the new WidgetKit framework, you can build widgets that can be added to your home screen to let you see important information at a glance. While you may be familiar with widgets in other operating systems, they are a completely new addition to iOS, and developers are already starting to build very exciting widgets using WidgetKit.
So let’s go ahead and build a new…
Developing apps in Xcode is great–most of the time, anyways.
In Xcode, Apple provides many features that can help improve developer productivity and make debugging easier. Below are the top 5 Xcode features that help me in my day-to-day iOS development workflow:
Testing animations can be tricky. Thankfully, Xcode has a feature that slows down animations in the simulator, that way you can see exactly how your views are moving or changing. To enable this feature, simply run your app, once in the simulator, click Debug in the top menu and then select Slow animations.
NavigationView
is SwiftUI’s counterpart to UIKit’s UINavigationController
. A NavigationView
is defined by Apple as “A view for presenting a stack of views representing a visible path in a navigation hierarchy”. In other words, it allows you to do hierarchical navigation between views and adds a navigation bar at the top of the screen.
SwiftUI’s default navigation bar is colored white with black text, and the opposite when dark mode is enabled.
In SwiftUI, there’s currently no simple way of customizing the top navigation bar (i.e. changing the navigation bar’s color). SwiftUI does support, however, the ability to create custom view…