Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I use segment combine with pageViewController, and create a view under my segment to be a bottom bar. It's weird when I use gesture to change my pageViewController content. My bottom bar's frame.origin.x always reset to below my segment's first section. But bottom bar moves normal when I tap segment. Could anyone can help? thanks.

demo video https://youtu.be/h2QUMNRZX_M

//this line print the right x in the view
print("buttonbar x: (self.buttonBar.frame.origin.x)")

DispatchQueue.main.async {

        UIViewPropertyAnimator.runningPropertyAnimator(withDuration: 0.3, delay: 0, animations: {
                //this line always print the x in the segment first section x
                print("x: (self.buttonBar.frame.origin.x)")
                self.buttonBar.frame.origin.x = (self.messageSegment.frame.width / CGFloat(self.messageSegment.numberOfSegments)) * CGFloat(self.messageSegment.selectedSegmentIndex) + self.messageSegment.frame.origin.x
            }, completion: { _ in
                print("x: (self.buttonBar.frame.origin.x)")
                
            })
        }
question from:https://stackoverflow.com/questions/65938725/segment-bottom-bar-combine-with-pageviewcontroller-didnt-work-well

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
350 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...