NOTE : This solution is broken in iOS 8. I will post new solution ASAP.
I am going to answer here using storyboard but it is also possible without storyboard.
-
Init: Create two
UIViewControllerin storyboard.- lets say
FirstViewControllerwhich is normal andSecondViewControllerwhich will be the popup.
- lets say
-
Modal Segue: Put
UIButtonin FirstViewController and create a segue on thisUIButtontoSecondViewControlleras modal segue. -
Make Transparent: Now select
UIView(UIViewWhich is created by default withUIViewController) ofSecondViewControllerand change its background color to clear color. -
Make background Dim: Add an
UIImageViewinSecondViewControllerwhich covers whole screen and sets its image to some dimmed semi transparent image. You can get a sample from here :UIAlertViewBackground Image -
Display Design: Now add an
UIViewand make any kind of design you want to show. Here is a screenshot of my storyboard

- Here I have add segue on login button which open
SecondViewControlleras popup to ask username and password
- Here I have add segue on login button which open
-
Important: Now that main step. We want that
SecondViewControllerdoesn’t hide FirstViewController completely. We have set clear color but this is not enough. By default it adds black behind model presentation so we have to add one line of code in viewDidLoad ofFirstViewController. You can add it at another place also but it should run before segue.[self setModalPresentationStyle:UIModalPresentationCurrentContext]; -
Dismiss: When to dismiss depends on your use case. This is a modal presentation so to dismiss we do what we do for modal presentation:
[self dismissViewControllerAnimated:YES completion:Nil];
Thats all…..
Any kind of suggestion and comment are welcome.
Demo :
You can get demo source project from Here : Popup Demo
NEW : Someone have done very nice job on this concept : MZFormSheetController
New : I found one more code to get this kind of function : KLCPopup
iOS 8 Update : I made this method to work with both iOS 7 and iOS 8
+ (void)setPresentationStyleForSelfController:(UIViewController *)selfController presentingController:(UIViewController *)presentingController
{
if (iOSVersion >= 8.0)
{
presentingController.providesPresentationContextTransitionStyle = YES;
presentingController.definesPresentationContext = YES;
[presentingController setModalPresentationStyle:UIModalPresentationOverCurrentContext];
}
else
{
[selfController setModalPresentationStyle:UIModalPresentationCurrentContext];
[selfController.navigationController setModalPresentationStyle:UIModalPresentationCurrentContext];
}
}
Can use this method inside prepareForSegue deligate like this
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
PopUpViewController *popup = segue.destinationViewController;
[self setPresentationStyleForSelfController:self presentingController:popup]
}