Move UIViews inside another UIViewController - ios

Have you used Tinder app?
That app is full of nice effects that makes a great UX experience in my opinion.
Try to open it and you see the launch image with a red flame at the center of the screen.
Seconds after the flame moves itself to the navigation bar to make the app logo.
The animation I am trying to create it exactly that and I can't figured out how to (1) let the navigation bar appear in that way and (2) to transition a custom UIView inside another view.
If I'd find an app to record the screen of my iPhone I will post a video explaining the animation I'm referring to.
In the meanwhile, do you have any ideas?

The animation I am trying to create it exactly that and I can't
figured out how to (1) let the navigation bar appear in that way and
(2) to transition a custom UIView inside another view.
Animation's are often not exactly what they seem to be. For example, when you segue from one view controller to another the animation you see often uses images instead of transforming the actual views.
You can do the same kind of thing for the animation you want. You don't have to actually move a view from one view controller to another -- just create the appearance that you did:
Create an animation that moves the image in question (like the flame) into position on top of the navigation bar.
Set the titleView of the destination view controller's navigation item to include the same image in the same location.
Remove the animated image. The user won't notice a change because the same image is already present at that location.

Related

How to make titleView remain in UINavigationBar during push/pop transition like Facebook app?

Here is a transitioning animation of UINavigationBar used in Facebook for iOS:
The topViewController is being changed, but the titleView is transitioning seamlessly.
(For your information, the two textfields are the same instance (checked with FLEX). However, I don’t care if the two textfields are not the same instance.)
What's the best way of approaching this?
Thanking you in anticipation.
I'm fairly confident that is not a navigation push/pop. I suspect what they're doing is hiding the left bar button to make the search field larger, and then just adding a view on top of the current VC's view. When you cancel, they hide the view and show the bar button. The clues I'm using to draw this conclusion are that (a) I've been writing iphone apps for years and I have no idea how to make a nav controller/bar do what you want with a push/pop, at least not without a lot of faking it and hoop jumping, (b) you video has the new view "pushing" from the wrong side, and (c) in my copy of the FB app, there is a different animation where the second view just appears/disappears without any push/pop animation.

iOS popover with a close button outside

I need to create below thing
Currently i'm using WYPopover , but I can't create the button since it's outside of the popover. Is there any existing solution out there ? Many thanks
Create a bigger popover UIView holding all your child elements (current popover + button) and make its background transparent or however you wish.
Popover-controller's are exclusively used in iPad. If you want to use in iPhone, you should create it in a custom way.
I am not familiar with the XYPopover in Github, but normally the custom created popover should be dismissed whenever the user taps any place in the screen. That is one of the key feature of the popovers.
Normally the custom popovers are build like, adding a hidden parent view and then the visible image of a popover frame on it.
You should to do the following,
Avoid dismissing the parent view on tap of parent-hidden-view.
Add a close button at the area where you want to show the close button, on top of the parent-hidden-view.
Capture the button click and dismiss the view (remove the view from superview)
How to customize your need
Creating custom popover view is not a big task. It will take maxim one day, try it your self.
One Parent view with clear color
One background image of a popover frame.
View-inside popover (this needs to be customized for UIPopover also).
Close button.

How do I make a now playing bar like in media player apps in iOS with XCode?

I am making a media player app. I have UITableViewControllers that are embedded in Navigation Controller. I would like to somehow make a view that would overlay potentially multiple (2?) of these tableviewcontrollers (one that shows the user's playlists, and the next would show the tracks in the playlist), but only at the bottom, like a now playing bar in (e.g.) Spotify's iOS app (as in the left bottom side of this
or as in this
I have tried to drag a Container View into my Navigation controller (in which my TableViewCell is embedded), but it won't let me drop it there.
It looks like I can drag the Container View into my TableView, but then how would it remain there when i navigate between tableviews?
Trying to follow #Rintaro's suggestion, but I'm a little new to XCode. How did you do this? So I made a single view application, i added a container view to the first VC, it's imm drawing it somewhere else in the storyboard, but i can't figure out how to tell that view that it's a navigation controller. also, as soon as i add a second container to the first VC and tried to size it, the first container disappears! It is still listed in the hierarchy on the left, and still has an arrow pointing out of it, but the view controller that was added and was being pointed to is also invisible?!
UPDATE: This works very well, but it has a problem with orientation changes. how can i make this work in both orientations? (I hypothesize that it currently positions the "nowplaying view" off screen when the orientation changes).
Basically, view hierarchy like that is constructed like this:
Using two "Container View" in initial view controller, one for Navigation Controller, one for "Now Playing Bar" view controller.
ADDED:
"Main Container View Controller" would be your own UIViewController subclass. It will have responsibility to show/hide "Now Playing Bar".
Workaround for Interface Builder strange behaviors.
You can set Auto Layout constraints like following. Maybe you might want to select the view from the left menu.
Note that, you should uncheck Constrain to margins check box.
Container View for Navigation Controller:
Container View for Now Playing Bar Controller:
And then, Update Frames from the menu:
If you are manually placing any buttons with absolute coordinates, make sure that you update the coordinates of them when the rotation is changed.
Obviously you need to create a custom UIView class, where you will show this menu. And when you will create it, add it to your view just like here:
float y = ROOTVC.view.frame.size.height - 49;
[self setFrame:CGRectMake(0, y, 320, 49)];
[ROOTVC.view addSubview:self];
[ROOTVC.view bringSubviewToFront:self];
I would simply add a nowPlayingView to the appDelegate.window and adjust either:
The window.rootController.view frame to avoid overlapping the nowPlayingView.
If window.rootController.view is a UIScrollView, adjust its contentInset.bottom to avoid overlapping the nowPlayingView. You can also use transparency/translucency with this solution.
Add a dummy toolbar to the controller that will get covered by the nowPlayingView.
If your window.rootController is a UINavigationController, then you have to probably do the above fore each controller you push. The nowPlayingView will stay unchanged on top.

Define modal view dimensions ?

I am developping a Master-Detail based iApp and I would like a specific button in the Master pane to trigger the apparition of a "settings" Form Window.
I then set my segue as "modal" and I get a form view covering the whole screen. This form comes from the bottom of the screen.
How do I get my view to appear from a slot at the top of the window and to cover, say, 2-thirds of the screen width and 3-quarters of its height?
Thanks!
You can't readily do it using the modal presentation styles, as they are fixed sizes. It is possible to work around but you need to mess around with resizing private views and it quickly starts to feel a bit fragile and messy.
It's simpler to create your own view controller at whatever size you like, add it as a child view controller and animate it into position yourself. You can even add your own background dimming view.
You lose the convenience of segues and the dismissal code, as you're no longer "presenting" the new VC, but that's not hard to recreate.

How can I place a UIView overlay above a modal view?

I have an informative overlay that I want to apply above a view controller presented as a modal. I've attempted all sorts of hacks to get the overlay (a transparent UIView) to be shown above the modal view controller without any luck.
The only thing that has had some success is adding the overlay as a subview of the main UIWindow but that negates a number of helpful features that the UIWindow provides (such as a rotation-independent coordinate system).
Is there another way to accomplish this?
Thats kind of the whole point of a modal view - its on top. The only think i can think of would be to add it as a subview of the modal view. This may require you to subclass the modal view and add in extra functionality there depending on what your actually working with
One idea that pops into mind is this:
Put your transparent overlay over the main view, launch your modal popover, add the transparent overlay again to your modal popover, but offset it's origin so that just that part of it that's needed to show within the popover space will line up with the overlay that's over the main view.
You might have an issue with getting the shading correct, but seems like it would be quick to try. Only downside I can visualize is that the borders of the popover might block some of it out.

Resources