DianQK / TransitionTreasury

Easier way to push your viewController.
https://transitiontreasury.com
MIT License
2.09k stars 157 forks source link

Twitter transition breaks topLayoutConstraint #11

Closed Rich86man closed 8 years ago

Rich86man commented 8 years ago

After performing a presentation with the twitter presentation method the top layout guide goes from 20pts to 0pts.

Here is the code I used to present the navigation controller

let vc = HealthPassportViewController.create()
vc.delegate = self
let nav = UINavigationController(rootViewController: vc)
nav.navigationBarHidden = true

tr_presentViewController(nav, method: TRPresentTransitionMethod.Twitter)

Before transition before

After transition after

I'm I doing something incorrectly? I've tried using the Fade transition and that does not create the same issue

DianQK commented 8 years ago

HiHi~@Rich86man Thanks you use TransitionTreasury. You can see the CHANGELING.md, I fix this Twitter Demo on 2.0 version.For more, see Stack Overflow Autolayout: Add constraint to superview and not Top Layout Guide?.

Do you use a trick NavgationBar? I see you have hidden native navgationBar. There is a AutoLayout Trick, when we use Twitter transition, HealthPassportViewController think there is no statusBar, so this view will move 20pts.

There is a picture from Stack Overflow: AutoLayout Trick

Maybe you can try to set View other than Top Layout Guide.

Hope this can help you. I have released 3.0.1 version which remove some unused code from TRStatusBarStyle.swift. Reckless.... Hope you love~

Rich86man commented 8 years ago

I could change the top constraint, but I'd prefer to keep it so I can reuse my view controller in situations were there may be a navigation bar, or status bar, or none of the above. I made a version of the twitter transition which uses snapshot views instead of the actual vc's view here : https://github.com/Rich86man/TransitionTreasury/commit/b8ce553a0853d4e298ec05d8a348f3c834e1695b

I can submit a pull request if you'd like

DianQK commented 8 years ago

Thanks your idea, but I found that: Preview

May be it is not good. And if someone want to do something at viewWillAppear(_:), nobody can see this.

So I can't merge, sooooooooo....sorry.

But if you like, you can try to Define a enum, just conform TransitionAnimationable.

You can see Twitter will look like ok when there is a navigation bar, I see you make a trick navigation bar, maybe you can taste a native navigation bar.