问题
The 3 main snapchat buttons are on the bottom on the screen, but as you swipe and move between different view controllers, they stay in the same position. Not only that, they also shrink and grow depending on which view you are in.
I'm trying to do something similar. I have a button at the top of my vc, and when I segue to another one I would like it to stay it there and still be functional.
回答1:
One possible way of going about this would be using a UIPageViewController
and setting it up to show the required UIViewControllers
at the appropriate indexes. You will have to programmatically add the buttons after subclassing the UIPageViewController
.
Alternatively:
You can also use UICollectionView
with full screen size cells and add the required UIViewController.view
at the proper indexes inside the UICollectionViewCell.contentView
. Add the buttons on top of the UICollectionView
and animate the button by increasing or decreasing the constraints based on the scrollView
contentOffset
回答2:
For complex animations you can achieve this by creating custom transition between view controller. Important to note is that in the transition logic you have to animate controller in such way that substitution of buttons will not be visible. Just when the first controller buttons have disappeared under them will be the second controller buttons.
回答3:
What I did for this was a scrollview with viewcontrollers within it. There are tutorials on youtube just search for snapchat scroll or snapchat menu system or w/e. Then I put the buttons on the scrollview, so as you slide to each view controller the buttons stay stationary. I also made a slider but it becomes pretty complicated. My slider is also disappearing when i navigate out and back, so there is a LOT of tweaking involved.
来源:https://stackoverflow.com/questions/40327355/snapchat-like-buttons-over-different-view-controllers