0

Goal: set .frame to open at maximum screen space

What I did:

ContentView()
.frame(minWidth: 700, idealWidth: .infinity, maxWidth: .infinity, minHeight: 500, idealHeight: .infinity, maxHeight: .infinity)

Problem: the frame still opens at the minHeight and minWidth.

Question: How can I set frame, so it will always open according to the full user device screen?

3
  • I did not tried by myself, but I think it must be done in this way, you have to read the monitor/screen size then set that size as frame. Commented Nov 8, 2021 at 16:35
  • 2
    try: .frame(minWidth: NSScreen.main?.frame.width, minHeight: NSScreen.main?.frame.height) Commented Nov 9, 2021 at 9:00
  • perfect, worked! I cannot accept this as answer as you commented, not answered. If you want to have it accepted please reply an answer : ) Commented Nov 9, 2021 at 10:25

1 Answer 1

2

you could try using:

 .frame(minWidth: NSScreen.main?.frame.width, minHeight: NSScreen.main?.frame.height)

works for me on macos 12.1 beta

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.