Last updated on April 29, 2020
Contrast allows you to either increase or decrease the differences in color. You may use contrast to either invert or intensify the color. By using contrast on a color, it will turn lighter color even lighter and darker color even darker.
Sets the contrast and separation between similar colors in the view.Apple Documentation
In this tutorial, you’ll learn what is Contrast in SwiftUI. You’ll learn:
- How to use Contrast.
To follow along this tutorial, you’ll need some basic knowledge in:
- A basic familiarity with Swift.
- At least Xcode 11
Negative contrast will invert the color. Invert the color here meaning flipping the bits that make up the pixels of the screen. For instance, the opposite color of white is black. It is essentially light color turning into dark color and vice versa.
Positive contrast will intensify the color give it a little darker look.
.frame(width: 50, height: 50)
As always, whatever effect applied on Color which is also a View can be applied on image as well.
.frame(width: 120, height: 120)
.overlay(Text("-5"), alignment: .bottom)
Where to go From Here
If you feel like you are ready to take on more challenges, feel free to check out some other tutorials that we have created: