美文网首页
SwiftUI—使用ScrollView在限定的区域显示超长的内

SwiftUI—使用ScrollView在限定的区域显示超长的内

作者: anny_4243 | 来源:发表于2020-07-16 10:08 被阅读0次

    原文链接:https://github.com/fzhlee/SwiftUI-Guide#-%E7%AC%AC9%E8%8A%82list-deleteandmove-

    本节课演示ScrollView的使用,滚动视图的功能和UIScrollView类似,主要用于在限定的区域显示超长的内容。

    示例代码:

    struct ContentView : View {
    
        var body: some View {
                ScrollView(.vertical, showsIndicators: false) { //添加一个滚动视图,第一个参数的值表示滚动方向为垂直方向,第二个参数的值表示不在滚动视图的右侧显示滚动条
                    VStack(alignment: HorizontalAlignment.leading, spacing: 20){
    
                        Text("Overview")
                        .font(.system(size: 48))
                        .padding(10)
                        Text("With the power of Xcode, the ease of Swift, and the revolutionary features of cutting-edge Apple technologies, you have the freedom to create your most innovative apps ever.\nSwiftUI provides views, controls, and layout structures for declaring your app's user interface. The framework provides event handlers for delivering taps, gestures, and other types of input to your app, and tools to manage the flow of data from your app's models down to the views and controls that users will see and interact with.")
                        .lineLimit(nil)
                        .frame(width: 300, height: 240, alignment: .topLeading)
                        .padding(10)
                        
                        Image("iPhone")
                        .resizable()
                        .frame(width: 300, height: 556, alignment: .center)
                    }
                }
                .background(Color.orange)
                .padding(10)
                .navigationBarTitle(Text("ScrollView"))
            }
        }
    

    相关文章

      网友评论

          本文标题:SwiftUI—使用ScrollView在限定的区域显示超长的内

          本文链接:https://www.haomeiwen.com/subject/pziuhktx.html