Meet iPhoneNumberField📱 — A TextField for phone numbers

And it’s as easy as


Context

This tutorial is for an iSwiftUI package. Learn more about iSwiftUI here.

A few months ago, I found myself trying to build one-time passcode input field for a login flow with SwiftUI. It wasn’t easy.

One time codes usually look like 6 or so different text fields that automatically switch to the next one when you type a number. The problem was that the SwiftUI TextField didn’t support programmatically switching text fields.

So my working solution was to make the text field transparent. And I made all the graphics just for show.

The obvious problem was the cursor. How do…


Context

This tutorial is for an iSwiftUI package. Learn more about iSwiftUI here.

I’ve found myself needing an easy way to add (pretty and dark-mode compatible!) dummy graphics to my SwiftUI on a few occasions, so if anyone else has too, here’s iGraphics!

Getting started

First, install iGraphics with the Swift Package Manager.

https://github.com/benjaminsage/iGraphics.git

If you haven’t done this kind of thing before, we’ve got detailed instructions on the process here.

Example 1: Shopping app

The iGraphicsBox automatically gives you the photo with caption graphic, and the easy stack(_:) modifier lets you add a bunch of them into a column super easily.

Example 2: Default graphics

The iGraphicsView is…


Context

This tutorial is for an iSwiftUI package. Learn more about iSwiftUI here.

When I was building my first SwiftUI app a while back, I got super hung-up on the Apple pay (PKPaymentButton) button. It seemed like I had to have, like, 4 layers of views just to get it to work properly. So, I finally packaged up the final version, and without further ado, Apple pay entirely in SwiftUI …

Getting started

First, install iPaymentButton with the swift package manager.

https://github.com/benjaminsage/iPaymentButton.git

If you haven’t done this kind of thing before, we’ve got detailed instructions on the process here.

A simple example

The most simple example…


Featuring 1) calling closures when the text is edited, 2) a binding to isEditing that you control 3) secure entry built in, and more. ⌨️

Context

This tutorial is for an iSwiftUI package. Learn more about iSwiftUI here.

A few months ago, when I was coding my first SwiftUI app, I found myself making like a dozen different UIViewRepresentable wrappers for UITextField every time I needed a new feature. So I made this! Lmk thoughts 😬

Getting started

First, install iPhoneNumberTextField with the Swift Package Manager.

https://github.com/benjaminsage/iTextField.git

If you haven’t done this kind of thing before, we’ve got detailed instructions on the process here. 🙂

A simple example

The most simple example of the text field looks like this:

The text field takes the usual placeholder and “text” binding. It…


Making a page view iOS 13-compatible entirely in SwiftUI 📖

Context

This LineChart tutorial is for an iSwiftUI package. Learn more about iSwiftUI here.

Getting started

First, install iPages with the swift package manager.

https://github.com/benjaminsage/iPages.git

If you haven’t done this kind of thing before, we’ve got detailed instructions on the process here.

A simple example

A super simple example of the SwiftUI page view looks like this:

The initializer takes two parameters:

  1. An array of the pages (Views) to be displayed
  2. A binding to the current page. If you change this, the view will swipe forward or backwards, and if the user swipes, this value will change.

Customizations

Since iPages is just a View, you can…


Format the user’s phone number as they type it, entirely in SwiftUI 📱🔢

Context

This tutorial is for an iSwiftUI package. Learn more about iSwiftUI here.

The iPhoneNumberTextField is like SwiftUI’s TextField or iSwiftUI’s iTextField, except it formats phone numbers while your user types, like this: (619) 876-5309.

Getting started

First, install iPhoneNumberTextField with the Swift Package Manager.

https://github.com/benjaminsage/iPhoneNumberTextField.git

If you haven’t done this kind of thing before, we’ve got detailed instructions on the process here.

A simple example

The most simple example of the text field looks like this:

The text field takes the usual placeholder and “text” binding. …


How to make SwiftUI colors from hex & integers + brand new names (Color.neonRed, etc.) 🎨

Context

This LineChart tutorial is for an iSwiftUI package. Learn more about iSwiftUI here.

Step 1: Install

Install iColor with the Swift Package Manager. If you’ve never done this before, step-by-step instructions here.

Step 2: Creating a color

There are 3 new & easy ways to create a color: by hex, integer RGBs, or name.

Way 1: By hex

Pass in a String hex value, with or without the ‘#.’

Way 2: By integers

Pass in your RGB values as integers from 0–255, like most design platforms that show your color channels. No need to divide by 255.

Way 3: By name

You’ve always been able to use color names like Color.red or Color.black, but now we’ve added a…

Benjamin Sage

iOS programmer using SwiftUI, AKA IcyHovercraft

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