WWDC23 SALE: Save 50% on all my Swift books and bundles! >>

Problem with "Hacking With macOS" Swift version - Project 6: Animation

Forums > Books

This may be a problem with my using a beta OS... I'm running MacOS Montery 12.5 beta (21G5056b) and Xcode Version 13.4.1 (13F100).

I've not been comprehensive in my attempt to debug this, but I have located a very simple example of the problem.

I create an Xcode project for AnimationSandbox and add the first set of code from the tutorial

Text("Click Me")
    .onTapGesture {
        // do nothing just yet
    }
    .padding(50)
    .background(.red)
    .foregroundColor(.white)
    .clipShape(Circle())
    .padding(100)

This works correctly in the preview - like the illustration in the tutorial - but when built and run, the text is missing. That is, I get a red circle with no text.

The problem appears to be caused by the .padding(100); if I comment this out

Text("Click me")
            .onTapGesture {
                    // do nothing just yet
                }
            .padding(50)
            .background(.red)
            .foregroundColor(.white)
            .clipShape(Circle())
            //.padding(100)

the preview and app match (what I take to be) correctly.

OK - the problem is that if the window size of the app is too small, the text doesn't appear. If I resize the window it works correctly.

Unfortunately it's taken me a couple of hours to understand this.

   

Save 50% in my WWDC23 sale.

SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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.