NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

SOLVED: Dealing with background color and safe areas

Forums > SwiftUI

I want to display the gradiant so that it uses all of the space leading, trailing and top of the YEAR TO DATE title. But as you can see in the imaged linked below the gradiant is still respecting safe areas even tho I try to ignore the safe areas. What am I doing wrong here? Any advice? Thank you everyone :)


Or put another way I want an effect like this:

                    ZStack {
                        LinearGradient(gradient: Gradient(colors: [Color.white, Color.purple]), startPoint: .leading, endPoint: .trailing)

                        VStack {
                            HStack {

                                    .frame(width: 17, height: 17, alignment: .leading)
                                    .clipShape(RoundedRectangle(cornerRadius: 5))

                                if readGenerateJSON?.first?.JSON_DurationMonths == 12 {
                                    Text("YEAR TO DATE")
                                if readGenerateJSON?.first!.JSON_DurationMonths ?? 0 < 12 {
                                    Text("PREVIOUS \(readGenerateJSON?.first?.JSON_DurationMonths ?? 0) MONTHS")




Hacking with Swift is sponsored by Judo

SPONSORED Let’s face it, SwiftUI previews are limited, slow, and painful. Judo takes a different approach to building visually—think Interface Builder for SwiftUI. Build your interface in a completely visual canvas, then drag and drop into your Xcode project and wire up button clicks to custom code. Download the Mac App and start your free trial today!

Try now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.