Xcode + Swift: Showing view on top of another - ios

When my app performs a certain segue, I want the new view to be shown on top of the previous view, like a background. How do I do this?
If this is not possible, is there any way I could programmatically take a screenshot of the previous screen to use as a background for the new screen?

There's a method on UIView, snapshotViewAfterScreenUpdates: than will give you a composite view of the current screen. You could use that for your background.
You might look into custom view transitions to do what you're after though.

Instead of a segue to a different view controller, why not just add the new view to the current controller, place it so that it appears above the first view and then set it as hidden.
When the user taps the action that would trigger the segue (a tableview cell for instance), then instead to triggering the segue, just mark the second view as visible and populate it's content with what you need to display.
With a clear background on the second view, it will overlay the original view. Then you can just add some control to hide it once they're through.

Related

Common bottom view which is Present in all other views and it is pull-able in iOS

I want to Show a common bottom view,which is present in all other view controllers even Navigation view doesn't hide this bottom view and this view has pull-Up, Pull-Down animations For Example Gaana App in AppStore
You can either add the button on keywindow of the app or make different view and call it on a single viewcotroller
second one is better than the first.
I recommended use This library some modification you get you want click here

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.

Designing view on top of multiple embed views

I have the task to design a application that has a main view which is always visible (it has a button on it's bottom side, and when pressed a image displays on top of all views), and a set of TableControllerView's that should appear under it, and the user needs to be able to navigate through them.
I know that you can embed a view inside another, but you cannot refer more than one view to it. The current way I'm trying to do now load one TableViewController inside the embed view, and when the user clicks the cell I manually load the other controller and add it as a child of the main view, which is the RootViewController. The problem with this approach is that the navigation bar gets stuck using the root view controller, so I have to manipulate the main navigation items on each subview transition, and second is that the frame for the second view I load is coming as it had full size, making some cells be under the main view button. This way doesn't uses segues for transition, so it makes the storyboard kinda useless.
I was thinking into using a TabViewController with it's tab hidden, but wanted to ask here for a better solution.
As you discovered, a TableViewController likes to fill up the whole screen (except navigation bars, tab bars, status bar, etc. which are official Cocoa Touch GUIs). When you want a table view to fill only part of the screen, you are supposed to use a UITableView but not a UITableViewController. You set your custom view controller object (subclass of UIViewController, not UITableViewController) as the table view delegate and data source. You will need to duplicate part of the functionality of UITableViewController in your custom view controller, but it's not a lot more than you have to do already to supply the data.
You should probably follow the standard design pattern and have separate view controller objects for each of the "pages" the user can navigate to. You just have a main button and image on each of them. But I could imagine why that might not give you exactly the effect you want.

Screen is not updating when segued from one view controller to another

I have a view controller (lets call it AViewController) which has a background image, buttons, etc. I also have a second view controller (lets call it BViewController) with its own set of buttons. When i transition from one view controller to another, the background image along with the UI Elements of the first view controller is being displayed in the second view controller. I am using a segue. I faced with problem before. What i did to correct it was change the background colour of the view from white to clear color. But it doesn't not seem to work in this case. (The BViewController contains a UIView in which the user can draw.)

iOS "slide in from left/right" view animations

My iOS6 app has a multi-level table view whose leaf nodes open up separate views. The animation from the first level of the table slides the old view out to the left and the new view in from the right. I'd like to also use this slide-in animation when transitioning from a table view to a non-table view. How?
Here's more info:
On the first level of the table view, there are disclosure Indicators . When one is clicked, the first level of the table slides off to the left and the second level view slides in from the right. Good.
On the second level of the table, there are Detail Disclosure Buttons which take the user to a detail view for that element in the table.
I'd like to offer the same animation here too: the table view should slide off to the left and the new view should slide in from the right.
First, am I correct that this is the correct animation to use in this case?
Second, do you know why this "slide in" animation isn't in the standard view animations in UIViewAnimationTransition below?
typedef enum {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;
Finally, if I do want to use the same slide in animation that table views use, but it's not available as one of the standard views, how should I add this animation when transitioning between a table view and a non-table view?
Typically this type of animation is done in a UINavigationController, and is the result of pushing a new viewController onto the stack. If you want to simulate it, all you need to do is add the newly exposed view to your current base view, to the right of the current view (i.e. off-screen) and use UIView's animateWithDuration:animations:completion: method to move both the on-screen and off-screen views one screen to the left. (Use the completion: block to remove the original view or leave it in place so you can easily animate it back on-screen.)

Resources