简体   繁体   English

如何使SwiftUI视图可滚动?

[英]How to make a SwiftUI view Scrollable?

How do I make my Body View as Scrollable? 如何将我的身体视图设为可滚动?

I need to make the large Lorem ipsum text scrollable. 我需要使大型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)
       //}
    }
}        

You can use List instead of ScrollView to enable scrolling. 您可以使用List而不是ScrollView来启用滚动。 Wrap your content in a List : 将您的内容包装在List

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

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM