Code snippet screenshot highlighting the topic of the article, containing the implementation of a Button in SwiftUI with title “Send Email” and of a custom view modifier called email composer that demonstrates the final result of this post.
Code snippet screenshot highlighting the topic of the article, containing the implementation of a Button in SwiftUI with title “Send Email” and of a custom view modifier called email composer that demonstrates the final result of this post.

Just a couple of weeks ago, I had discussed in this previous post about the MFMailComposeViewController; a class that allows to present and use a system provided view controller in order to compose and send emails through our own applications. The discussion on that post was around a UIKit based application explaining how that class works.

In this post today, I’m going to talk about how to integrate MFMailComposeViewController in SwiftUI projects, since there is no native SwiftUI alternative. …


A woman hand holding an iPhone and taking picture of the table right under. On the table there is an open book, with eye glasses, coffee, a small decorative plant and decorative table cloth. On top of the image the AsyncImage in SwiftUI title is written, and SerialCoder.dev with small letters at the bottom.
A woman hand holding an iPhone and taking picture of the table right under. On the table there is an open book, with eye glasses, coffee, a small decorative plant and decorative table cloth. On top of the image the AsyncImage in SwiftUI title is written, and SerialCoder.dev with small letters at the bottom.
Credits: Photo by Ylanite Koppens from Pexels

At the time of writing this post, WWDC21 is still in progress. And as it turns out, this year’s announcements reveal really great and exciting news for developers. Among them, SwiftUI seems that has been equipped well with new APIs, views and tools that will undoubtedly make building apps with it an even more easier and fun task.

A new and quite interesting view introduced in this, third release of SwiftUI, is the AsyncImage. As the name makes it pretty obvious, this view displays images after having fetched them from a remote URL. Doing so has been traditionally a manual…


An iPhone’s screen portion showing default email app icon among others.
An iPhone’s screen portion showing default email app icon among others.
Photo by Torsten Dettlaff from Pexels

It’s often needed to add email sending functionality to iOS apps. In order to do that, there is a specific view controller to use called MFMailComposeViewController. When presented, it brings up the familiar system controller to compose and send an email. It’s possible to provide default values before its presentation, such as the subject or the recipients, even a predefined email body. In overall, sending email is a quite standard procedure, and this post will take you through the integration steps of the email composer on iOS.

Initial steps

The first step towards presenting the system controller to compose and send emails…


As developers, we use initializers all the time to create instances of various types. We also create our own initializers when implementing custom classes or structs. But should initializers always return an instantiated object of the type they are implemented into?

It makes sense sometimes not to return an object if the initialization of one or more properties that play crucial role in the type does not succeed. A failable initializer in Swift is an initializer that allows to do that, as it can potentially return nil if one or more conditions are not satisfied.

A hands-on example

Let’s see an example to…


Solid greenish background with with text saying TextEditor in SwiftUI
Solid greenish background with with text saying TextEditor in SwiftUI

SwiftUI is great, but it has been lacking of specific native controls, even though that gets much better year by year. One of them was the text view. When SwiftUI was first released, it had no native equivalent of the text view; implementing a custom UIViewRepresentable type to contain UITextView was the only way to go. But since iOS 14, SwiftUI introduces TextEditor, a brand new view to write multi-line text.

Using TextEditor is almost as simple as any other SwiftUI view, with most of common view modifiers to apply here too. …


Swift has several small features as a language, many of them being neglected quite often while they consist of small programming gems. One of them is the @discardableResult attribute that everybody wish they knew from the beginning.

What’s the purpose of @discardableResult? Put in simple words, when used to annotate a method, then the returned value of the method can be ignored when it gets called.

Let’s make that clear through a basic example. Say that we have the following method that stores the text given as first argument to the file name provided as second argument:

func save(text: String…

In the first part of the Working With Property Lists in Swift series, I showcased through a simple example how easy it is to use plist files in order to read and save data. Using the PropertyListEncoder and PropertyListDecoder classes along with the Codable type, encoding and decoding to and from property lists is just a matter of a couple of lines.

However, there is a downside. Codable work instantly out of the box when all properties in a custom type are of basic data types; numbers, string, data, boolean, and a few more (you can find them all in…


A property list file, better known as a plist file, is a specific kind of file that can store data in key-value pairs. In fact, property list files are XML files simply named differently in the Apple ecosystem. Making a parallelization, plist files are similar to dictionaries in Swift; the collection type that can also store key-value pairs of data.

The best example of a property list file, is the Info.plist in every Xcode project. It contains a big number of default settings, configuration and information regarding the app, but more entries can be added on demand. …


Welcome to a short, yet a quite useful post regarding SwiftUI. Today I’m going to show you how it can become possible to round only specific corners of a SwiftUI view. Doing so is usually necessary when we want to decorate views with a different style, and as you will see here it’s actually really easy to achieve it.

Starting by the fact that SwiftUI does not provide a native, built-in way to round certain corners of a view, it becomes obvious that coming up with a custom solution is an unavoidable task. …


One of the most used controls in SwiftUI is the Button view. When creating buttons, a default style is applied to them. For simple cases where customization is not necessary, the predefined style works well; it creates a borderless button with a default highlight appearing when tapped.

As an example, suppose that we have the following button:

With the default button style and without any customization, here is how the button responds when tapped:

Gabriel Theodoropoulos

An iOS & macOS app maker writing code in Swift. Author of countless programming tutorials. Content creator. https://serialcoder.dev

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store