### Carthage installation for PagerTabStripView Source: https://github.com/xmartlabs/pagertabstripview/blob/master/README.md Add this line to your Cartfile to install PagerTabStripView version 4.0 or later via Carthage. ```ruby github "xmartlabs/PagerTabStripView" ~> 4.0 ``` -------------------------------- ### CocoaPods installation for PagerTabStripView Source: https://github.com/xmartlabs/pagertabstripview/blob/master/README.md Add this line to your Podfile to install PagerTabStripView version 4.0 or later via CocoaPods. ```ruby pod 'PagerTabStripView', '~> 4.0' ``` -------------------------------- ### Custom style with barButton and custom views Source: https://github.com/xmartlabs/pagertabstripview/blob/master/README.md Example of building a custom style using .barButton with custom animations, tab item height, a gradient background view, and a custom indicator view (a text emoji). ```swift .pagerTabStripViewStyle(.barButton(placedInToolbar: false, pagerAnimation: .interactiveSpring(response: 0.5, dampingFraction: 1.00, blendDuration: 0.25), tabItemHeight: 48, barBackgroundView: { LinearGradient( colors: 🌈, startPoint: .topLeading, endPoint: .bottomTrailing ) .opacity(0.2) }, indicatorView: { Text("👍🏻").offset(x: 0, y: -24) })) ``` -------------------------------- ### Create a PagerTabStripView with pagerTabItem modifier Source: https://github.com/xmartlabs/pagertabstripview/blob/master/README.md Basic usage: place custom tab views inside PagerTabStripView and apply the pagerTabItem modifier with a unique Hashable tag. The example shows conditional inclusion of a tab based on User.isLoggedIn. ```swift import PagerTabStripView struct MyPagerView: View { var body: some View { PagerTabStripView() { MyFirstView() .pagerTabItem(tag: 1) { TitleNavBarItem(title: "Tab 1") } MySecondView() .pagerTabItem(tag: 2) { TitleNavBarItem(title: "Tab 2") } if User.isLoggedIn { MyProfileView() .pagerTabItem(tag: 3) { TitleNavBarItem(title: "Profile") } } } } } ``` -------------------------------- ### Button bar style with custom settings Source: https://github.com/xmartlabs/pagertabstripview/blob/master/README.md Example of using the .barButton style with settings like tabItemSpacing, tabItemHeight, and a custom indicator view. The PagerTabStripView is created with two tabs and a conditional tab based on user login. ```swift struct PagerView: View { @State var selection = "Tab 1" var body: some View { PagerTabStripView(selection: $selection) { MyView() .pagerTabItem(tag: "Tab 1") { TitleNavBarItem(title: "Tab 1") } AnotherView() .pagerTabItem(tag: "Tab 2") { TitleNavBarItem(title: "Tab 2") } if User.isLoggedIn { ProfileView() .pagerTabItem(tag: "Profile") { TitleNavBarItem(title: "Profile") } } } .pagerTabStripViewStyle(.barButton(tabItemSpacing: 15, tabItemHeight: 50, indicatorView: { Rectangle().fill(.gray).cornerRadius(5) })) } } ``` -------------------------------- ### Apply scrollableBarButton style with custom settings Source: https://github.com/xmartlabs/pagertabstripview/blob/master/README.md Use the pagerTabStripViewStyle modifier with .scrollableBarButton to customize tab item spacing, height, and indicator view. The example sets tabItemSpacing to 15, tabItemHeight to 50, and a blue rounded rectangle indicator. ```swift struct PagerView: View { @State var selection = 1 var body: some View { PagerTabStripView(selection: $selection) { MyView() .pagerTabItem(tag: 1) { TitleNavBarItem(title: "First big width") } AnotherView() .pagerTabItem(tag: 2) { TitleNavBarItem(title: "Short") } ... .. . } .pagerTabStripViewStyle(.scrollableBarButton(tabItemSpacing: 15, tabItemHeight: 50, indicatorView: { Rectangle().fill(.blue).cornerRadius(5) })) } } ``` -------------------------------- ### Set initial selection with selection parameter Source: https://github.com/xmartlabs/pagertabstripview/blob/master/README.md Pass a @State variable to the selection init parameter to specify the initial selected page. The value must match a tag value of the tab items. ```swift struct MyPagerView: View { @State var selection = 1 var body: some View { PagerTabStripView(selection: $selection) { MyFirstView() .pagerTabItem(tag: 1) { TitleNavBarItem(title: "Tab 1") } ... .. . } } } ``` -------------------------------- ### SwiftUI custom navigation bar item with title Source: https://github.com/xmartlabs/pagertabstripview/blob/master/README.md Defines a custom tab bar item view for PagerTabStripView. The view displays a title with gray subheadline text on a white background, filling the available space. Use this as a template for creating custom tab bar items. ```swift struct TitleNavBarItem: View { let title: String var body: some View { VStack { Text(title) .foregroundColor(Color.gray) .font(.subheadline) } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color.white) } } ``` -------------------------------- ### Disable left edge swipe gesture with edgeSwipeGestureDisabled Source: https://github.com/xmartlabs/pagertabstripview/blob/master/README.md Configure swipe gesture edges using edgeSwipeGestureDisabled with a HorizontalContainerEdge OptionSet. This prevents parent view gestures from interfering when swiping left on the first page. ```swift struct MyPagerView2: View { @State var selection = 1 var body: some View { PagerTabStripView(edgeSwipeGestureDisabled: .constant([.left]), selection: $selection) { MyFirstView() .pagerTabItem(tag: 1) { TitleNavBarItem(title: "Tab 1") } ... .. . } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.