gpt4 book ai didi

ios - 如何使 SwiftUI View 可滚动?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:10:19 25 4
gpt4 key购买 nike

如何使我的 Body View 可滚动?

我需要使大型 Lorem ipsum 文本可滚动。

struct FeatureDetail : View {
var body: some View {
//Scrollable { Does Not work
VStack{
Image("wwdc")
.resizable()
.aspectRatio(contentMode: .fit)
.padding()

Text("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.").lineLimit(nil).padding(20)

}.navigationBarTitle(Text("WWDC"), displayMode:.automatic)
//}
}
}

最佳答案

您可以使用 List 而不是 ScrollView 来启用滚动。将您的内容包装在 List 中:

List {
VStack{
Image("wwdc")
.resizable()
.aspectRatio(contentMode: .fit)
.padding()

Text("Very long text").lineLimit(nil).padding(20)

}.navigationBarTitle(Text("WWDC"), displayMode:.automatic)
}

关于ios - 如何使 SwiftUI View 可滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56503728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com