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
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.
If you try to limit the amount of chars the user…
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…
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. …
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:
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.
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…