@@ -51,11 +51,7 @@ open class PuiPageViewSegmentedControl: UIView {
5151
5252 open override func layoutSubviews( ) {
5353 super. layoutSubviews ( )
54-
55- // Update pages size
56- for page in self . pages where page. view. superview != nil {
57- page. view. frame. size = self . bounds. size
58- }
54+ self . updateContainerView ( )
5955 }
6056
6157 public func configure( pages: [ UIViewController ] ,
@@ -79,20 +75,34 @@ open class PuiPageViewSegmentedControl: UIView {
7975 self . containerView. bounces = true
8076 self . containerView. alwaysBounceHorizontal = true
8177 self . containerView. alwaysBounceVertical = false
78+ self . containerView. showsHorizontalScrollIndicator = false
79+ self . containerView. showsVerticalScrollIndicator = false
8280 self . containerView. isPagingEnabled = true
8381 self . containerView. delegate = self
8482 self . containerView. scrollsToTop = false
8583 self . addSubview ( self . containerView)
8684
85+ self . updateContainerView ( )
86+
87+ // Add default view controller
88+ self . addViewController ( at: self . currentIndex)
89+ }
90+
91+ private func updateContainerView( ) {
92+ self . containerView. frame. size = self . bounds. size
93+
8794 // Calculate content offset according to current index
8895 self . containerView. contentOffset = CGPoint ( x: self . bounds. size. width * CGFloat( self . currentIndex) , y: 0 )
8996
9097 // Calculate total content size according to page count
9198 self . containerView. contentSize = CGSize ( width: self . bounds. size. width * CGFloat( self . pages. count) ,
9299 height: self . bounds. size. height)
93100
94- // Add default view controller
95- self . addViewController ( at: self . currentIndex)
101+ // Update pages size
102+ for index in 0 ..< self . pages. count where self . pages [ index] . view. superview != nil {
103+ self . pages [ index] . view. frame. size = self . bounds. size
104+ self . pages [ index] . view. frame. origin. x = self . getPosition ( at: index)
105+ }
96106 }
97107
98108 private func updateContent( ) {
0 commit comments