PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 29, 2022

[FIXED] How to allow an image to extend beyond a Form {} in SwiftUI?

 July 29, 2022     forms, image, swiftui, xcode     No comments   

Issue

I'm looking to have an image extend above a form, as pictured in the first attached screenshot below. My code below accomplishes this when I run it on the Simulator using a iPod touch (7th Generation), but produces the second screenshot when I run it on iPhone 12 and iPhone 13. Any advice about how to ensure that the image extends beyond the limits of the form as intended on all devices?

struct ContentView: View {
    var body: some View {
        Form {
            Circle()
                .frame(width: 100, height: 100)
                .clipShape(Circle())
                .offset(y: -50)
                .padding(.bottom, -50)
        }
    }
}

enter image description here

enter image description here


Solution

Form uses different styles on different devices. A possible solution is to use instead List with explicit style for all devices.

Tested with Xcode 13.4 / iOS 15.5

demo

    List {
        Circle()
            .frame(width: 100, height: 100)
            .clipShape(Circle())
            .offset(y: -50)
            .padding(.bottom, -50)
    }
    .listStyle(.grouped)   // << here !!


Answered By - Asperi
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing