TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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.

3      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.