简体   繁体   中英

XCode iOS - How to animate position of a UICollectionView? (Slide in from bottom of screen)

I am trying to build what is essentially a photo editing app where I can place "stamps" onto an image.

I am using a UICollectionView to contain all the stamps to choose from.

What I am trying to accomplish is have this collection view slide in from the bottom of the screen when the "Stamps" button is pressed from the main view.

Currently the collection view exists on the Storyboard with a Y position of 568 (bottom of an iPhone 5 screen - not visible).

I'm not an XCode veteran by any means so sometimes I am not aware of "best practices" when it comes to this kind of functionality that is commonly seen in apps today.

Is it better to try and animate the UICollectionView itself? Or is it better to try and place the collection view into its own UIView and animate that view?

Since I want this app to be used on iPhone 5 and larger screen of the iPhone 6, I'll make sure to take care of dynamically resizing the collection view and it's contents before the animation takes place.

Anyhow if anyone has any insight on the most efficient way to achieve this slide-in-from-bottom animation, using certain animation classes etc., on a collection view, that would be a great help! I am attaching an animated GIF to illustrate the effect I am going for.

在此处输入图片说明

Use - (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion method to present a view controller instead of animating view. It also helps keep your code segregated. Happy coding!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM