Make custom colour pickers and reuse them in any project with Swift Package Manager
iOS 14 brings updates to the SwiftUI API, and that means we get some new Views to use in our apps. It might be a surprise to learn that we now have a
ColorPicker, which we can use simply by passing a Binding for a colour that we want to pick. This makes it much easier than ever before to choose a custom colour in our iOS, iPadOS and MacOS apps, but what about when we want custom controls? The ColorPicker as it is seems to have a fairly rigid set of controls that can’t be changed by the developer.
What if we want different controls?
What if we want the controls to look how we want them to look?
If we make our own, we can do whatever we want!
I should probably explain how I got to that 1,500+ number in the headline.
This will show I’m not exaggerating while showing everything you’ll learn, so it serves multiple purposes.
We are using four colour spaces for these colour pickers:
Every picker you’ll make in this tutorial occupies a single colour space and allows you to set every parameter without having several controls for the same parameter.
Below are the controls you’ll make:
Canvases use the x and y coordinates to pick two parameters at once (hue/saturation in this case)
You’ll learn to create canvases, which allow you to pick a point on a square. If the _x-_axis is brightness and the _y-_axis is saturation, the coordinates of the point you pick will set both of these parameters.
SwiftUI was announced at WWDC 2019 and it paved a way for declarative programming for building interfaces. SwiftUI Grid comes in two different flavours, which includes LazyVGrid and LazyHGrid. As the name suggest, LazyVGrid is a Grid that flows in vertical direction and the LazyHGrid flows in horizontal direction
A great place to start building with SwiftUI
SwiftUI was announced at WWDC 2019 and it paved a way for declarative programming for building interfaces. SwiftUI Grid comes in two different flavours, which includes LazyVGrid and LazyHGrid. As the name suggest, LazyVGrid is a Grid that flows in vertical direction and the LazyHGrid flows in horizontal direction.
SwiftUI was inevitably going to see big changes this year, and I'm really excited to experiment with them all – text views, color pickers, progress
AppClues Infotech is a top Mobile App Development Company in USA building high-quality Android, iOS, and Native apps for Startups, SMBs, & Enterprises. Contact us now!