article

Friday, September 24, 2021

SwiftUI Simple TabView(PageTabView)

SwiftUI Simple TabView(PageTabView)
ContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
//  ContentView.swift
//  Swiftuitest
//
//  Created by Cairocoders
//
 
import SwiftUI
 
struct ContentView: View {
     
    private var imageNames:[String] = ["1", "2","3","4","5","6","7"]
    var body: some View {
         
        TabView {
            TabView {
                ForEach(imageNames, id:\.self) {
                    imageNames in
                     
                    Image(imageNames)
                }
            }.tabViewStyle(PageTabViewStyle())
        }.frame(width: UIScreen.main.bounds.width - 20, height: 300, alignment: .center).cornerRadius(10)
    }
}
 
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Related Post