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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…