Closed boompikachu closed 4 years ago
This bug doesn't occur when wrap in NavigationView
Hi @boompikachu ,
I have a workaround for you because this seems like a SwiftUI issue. I'm debugging your code on an iPhone Pro Max, the available space for Pager
is (412.0, 769.0)
. If no itemAspectRatio
provided, this is the size that's set to the page. Now, if you apply .frame(width: 412, height: 769)
to SecondView
, you still have the problem. Try setting one pixel less for the height and your problem is solved, .frame(width: 412, height: 768)
.
So the workaround is this: use padding(1)
to give 1 pixel of top and bottom padding to the Pager
and it works perfect.
Pager(page: self.$page,
data: items,
id: \.self,
content: { item in
SecondView()
}).padding(1)
When inserting a View() that has a fullscreen ScrollView() in Pager(), the Pager() will have a padding issue on the top and the bottom of the ScrollView(). From my findings (not sure), the Pager() does follows the safe area while the View() inside the Pager() doesn't causing the Pager() to cut some portion of the ScrollView() out. This can be seen in the following photo:
ContentView()
` import SwiftUI import SwiftUIPager
`
SecondView()
` import SwiftUI
`
I found the temporary fix which is to add padding to the ScrollView() but this will cause a small white line between the view and the nav bar as follows: