Home > AI > IOS > SwiftUI >

PageTabViewStyle

Example 1: a simple demonstration (horizontal effect)

struct ContentView: View {
    var body: some View {
        TabView {
            
            Image(systemName: "pencil")
                .resizable()
                .aspectRatio(contentMode: .fit)
            
            Image(systemName: "pencil.and.outline")
                .resizable()
                .aspectRatio(contentMode: .fit)
            
            Image(systemName: "paperplane")
                .resizable()
                .aspectRatio(contentMode: .fit)
            
        }
        .tabViewStyle(PageTabViewStyle())
        .background(Color.blue)
    }
}

Example 2: hide indicators

PageTabViewStyle(indexDisplayMode: .never)

Example 3: vertial effect

struct ContentView: View {
    var body: some View {
        TabView {
            Group {
                Image(systemName: "pencil")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                
                Image(systemName: "pencil.and.outline")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                
                Image(systemName: "paperplane")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
            }.rotationEffect(Angle(degrees: -90))
            
        }
        .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
        .background(Color.blue)
        .rotationEffect(Angle(degrees: 90))
    }
}

Leave a Reply