DEV Community

Sean Walker
Sean Walker

Posted on

Do Good Daily Day 6

📅 09/17/2019
🔥 6 day streak
📱 Do Good Daily
💰 $0.99 price
🤑 0 sales
⌚️ 5.5 hours spent
💻 37 files changed 554 additions(+) 81 deletions(-)
✅ Today's goal: Finish up rough versions of intro views

SwiftUI is better than web development

When it works it really works. Today the preview feature was working well and I managed to breeze through a few more static screens with simple buttons. It's insane that all it takes to make something very custom looking is ~70 lines of code per screen, if you can even call it code. It definitely makes me wonder what the heck we're doing out there in web development land. Anyway, I did learn a few SwiftUI tricks that I thought I'd share

SwiftUI full screen background image

var body: some View {
        VStack {
        }
        .background(
            Image("bg")
            .resizable()
            .scaledToFill()
            .edgesIgnoringSafeArea(.all)
        )
}
Enter fullscreen mode Exit fullscreen mode

That's all it takes. Either that or a ZStack and put the image as the first child.

SwiftUI center an image

Or anything really. It's funny I was messing around with this problem for a while but I came up with something pretty decent, assuming you only have one thing to center

var body: some View {
        VStack {
             Spacer()

             Image("bg")

             Spacer()
        }

}
Enter fullscreen mode Exit fullscreen mode

There's some more code with some other goodies but there's always tomorrow.

Top comments (0)