You now have a fully functioning, powerful, and native color picker that you can use anywhere in your app. The function should now look like this private func selectColor() Īnd that’s it. You can also use the copy buttons to copy corresponding color values directly. Using the colorPicker variable we can access several properties of the CPVC such as setting the initial color, setting a settingAlpha boolean that will let users choose the opacity/alpha of the color. Drag your mouse from the preview area to the point from where you want to pick color, and the preview area will show the pixels around that point with HEX, RGB, and HSL color values of the point to the right. This function will be used to configure and present the ColorPicker view controller on top of our parent view controller. Your class properties should now look like this: private var pickedColor = UIColor.systemTeal private var colorPicker = UIColorPickerViewController() Creating a selectColor Function We have to create another property that is an object of the brand new UIColorPickerViewController class. Let us initially set its value to UIColor.systemTeal because, fun fact, Teal is my favorite color. We’ll store this color property in a variable called pickedColor. For this example, we’ll change the background color of this view controller when the color picker view controller returns us a new color. The first thing we’ll do is configure our parent view controller. Universal- Available on iOS, iPadOS and with Catalyst on macOS.Transferable Pallets- Picked colors from the color picker can be accessed from anywhere.Powerful- Colors can be picked from 3 different modes and it provides a screen picker which can be used to pick colors from anywhere on the screen.Native- adapts to system fonts, themes.Here are some of the main features of this new control. One of the best new additions is the system Color Picker. WWDC 2020 brought many new UIControl APIs to iOS, iPadOS, and macOS. A Brand new ColorPicker introduced at WWDC 2020
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |