Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

uisegmentedcontrol - segment bottom bar combine with pageViewController didn't work well

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

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...