![](/img/trans.png)
[英]How to remove the side padding from the Graphical Style DatePicker in SwiftUI?
[英]How to remove padding from the left side of list of navigation links? SwiftUI
我正在開發一個應用程序,其中有一個圖像導航鏈接列表。 我希望圖像是屏幕的整個寬度,但左側有填充。 我嘗試了幾件事:
.frame( maxWidth: .infinity)
.ignoresSafeArea()
.listStyle(PlainListStyle())
NavigationView {
VStack {
Text("Available guides in: ").padding(.bottom, -1000).padding(.top,100).font(.custom("SF Mono-Light", size: 28)).edgesIgnoringSafeArea(.all)//.foregroundColor(Color.white)
Text("Somewhere").padding(.bottom, -90).padding(.top,-70).font(.custom("SF Mono-Light", size: 32))//.foregroundColor(Color.white)//.edgesIgnoringSafeArea(.all)
List {
ForEach(guides) { guide in
NavigationLink(destination: GuideView(guideSessionManager: GuideSessionManager(guide: guide)), tag : guide.guideName, selection: $selection) {
Button(action: {
selection = guide.guideName
}) {
Image(guide.imageName)
.renderingMode(Image.TemplateRenderingMode?.init(Image.TemplateRenderingMode.original))
}.buttonStyle(GrowingButtonImage())
.frame( maxWidth: .infinity)
.ignoresSafeArea()
}
.frame( maxWidth: .infinity)
.listRowInsets(EdgeInsets())
.ignoresSafeArea()
}
}
.frame( maxWidth: .infinity)
.ignoresSafeArea()
.listStyle(PlainListStyle())
.frame( maxWidth: .infinity)
.ignoresSafeArea()
.listStyle(PlainListStyle())
您在不帶參數的情況下為其提供EdgeInsets
並將寬度設置為 .infinity 與.ignoresSafeArea
,這會導致奇怪的交互。 要么刪除.ignoresSafeArea
,在EdgeInsets
上使用參數,要么不使用.infinity
List {
ForEach(guides) { guide in
NavigationLink(destination: GuideView(guideSessionManager: GuideSessionManager(guide: guide)), tag : guide.guideName, selection: $selection) {
Button(action: {
selection = guide.guideName
}) {
Image(guide.imageName)
.renderingMode(Image.TemplateRenderingMode?.init(Image.TemplateRenderingMode.original))
}
.buttonStyle(GrowingButtonImage())
.frame( maxWidth: .infinity)
.edgesIgnoringSafeArea(.all)
}
// Modify these to your liking
.listRowInsets(EdgeInsets(top: 0.0, leading: 0.0, bottom: 0.0, trailing: 0.0))
}
您也可以嘗試使用.scaledToFill()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.