Sign in

Mobile- / Frontend Developer
Photo by Anton Maksimov juvnsky on Unspla

To style a button with some predefined style inside your app you would usually use the buttonStyle method and apply one to it (e.g DefaultButtonStyle). In terms of accessibility it is most often recommended to stick with these button styles, but (as most developers probably know) in some cases the design dictates otherwise and you need more customization.

Creating and applying a view modifier could be an easy and quick solution to accomplish the desired effect, without the need of repeated code — but there is a more idiomatic way in swift programming by adopting a common protocol: ButtonStyle

Photo by Patrick Fore on Unsplash

Sometimes you need to limit the amount of characters a user can enter into an input field in your app — for example when implementing an input for zip codes.

From UIKit you might be familiar with the textField(_:shouldChangeCharactersIn:replacementString:) method to limit the characters for a UIKit TextField.

The TextField in SwiftUI seems to lack of such functionality as it provides us with no callback or method to accomplish such task, but there’s still a way to solve this — you only need to change the way of thinking.

The problem

If you try to limit the amount of chars the user…

Get your Ruby programs up and running on Apple’s ARM-based processor

An aerial shot of a Macbook sitting on a table.
An aerial shot of a Macbook sitting on a table.
Photo by Karthikeya GS on Unsplash

The Problem

With the Apple Silicon M1 Macs, we got a brand new macOS, universal binaries, and a new set of command-line tools for Xcode. As always, the package came with an installation of Ruby, but for the first time, it came with a universal binary to support both ARM and Intel CPUs — and with that a journey begins.

For experienced Ruby developers, this story may be nothing new and/or in unnecessarily complicated. I just want to share my experience, insights, and results here.

While playing around with the M1, I soon ran into some problems in running Ruby programs. It…

Photo by Markus Spiske on

Swift can be a wonderful language, when it comes to command line tools and scripting, especially since it’s available on various platforms including Linux and Windows - but can also be tricky sometimes when you’re coming from iOS or macOS programming, as some things need to be done differently or might not work the way you would expect them.

Asynchronous request are one of such things when used in command line code…

Note: Swift 5.x or later is required and it’s assumed you already have some knowledge about programming in Swift. …

Add a beautiful blur or bokeh effect to your images

blurry colored lights illustrating the bokeh effect
blurry colored lights illustrating the bokeh effect
Photo by Simon Abrams on

Blur effects on backgrounds, views, and other elements can have many advantages in modern UI/UX design and software development, whether for getting the user’s attention and focus or to simply make things look great.

As an iOS user, you probably already know such kinds of effects pretty well as they’re used on various functions inside the operating system itself. A famous example is opening the Spotlight search on an iPhone:

Photo by Ramshid ekl on

There are numerous reasons a user could want to clear a value inside a text field, whether it’s a typo or just for entering completely new things and everyone knows how cumbersome it can become to clear long text on a mobile device inside a small field.

Accordion views made simple

Photo by Aditya Vyas on Unsplash.

In app development, you often have the requirement for some kind of collapsible view. With the release of iOS 14 and Xcode 12, we will have the luxury of DisclosureGroup view elements to achieve that for us. But until its release — and for apps that need some backward compatibility — you have to provide your own custom solution for that.

In this article, I want to show you a simple approach to creating your own custom collapsible view in SwiftUI. Let’s get started!

Note: XCode 11.x, Swift 5.x, and iOS 13.x are required. It’s assumed you already have some…

Martin Albrecht

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