To use this, simply download the whole project and drag and drop the MRPopOver group folder to your own project. There are three ways you can use this project.
NOTE: This does not support orientation changes. That part you will have to handle on your own. Also ensure that you create the provided pop overs after calling animations on the view pop up appears from or animate the pop over along with the button.
You can show a view controller from any view of that you decided. It will adjust itself to fit across the whole width and remaining height. If the view from which you wish to display the pop over is present in the top part of the screen, the pop over will appear from the view all the way to the bottom of the screen. If the view is present in the bottom half of the screen, the pop over will appear from the view to the top part of the screen. Have a look at the screenshot:
//instantiate whichever view controller you wish to show
UITableViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"table"];
MRPopOverViewController *viewControllerNew = [[MRPopOverViewController alloc] initFromView:sender withViewController:viewController];
[self presentViewController:viewControllerNew animated:YES completion:nil];
@property (strong, nonatomic) UIColor *trianglePopUpColor;
@property (strong, nonatomic) UIColor *colorOfBorder;
@property (assign, nonatomic) CGFloat borderWidth;
@property (assign, nonatomic) CGFloat cornerRadiusForPopOver;
@property (assign, nonatomic) CGFloat shadowRadius;
@property (strong, nonatomic) UIColor *shadowColor;
@property (assign, nonatomic) CGSize shadowOffset;
@property (assign, nonatomic) CGFloat shadowOpacity;
@property (assign, nonatomic) UIEdgeInsets edgeInsets;
@property (assign, nonatomic) CGFloat triangleWidth;
@property (assign, nonatomic) NSNumber *totalHeight;
Also there is a delegate to notify you whenever the user decides he wants to close the screen by tapping outside:
Just make your class conform to the MRPopOverViewControllerDelegate
and set it using:
viewControllerNew.delegate = self;
To peform some action just write the function inside your class:
-(void)userDidDismissViewController;
Note: Set the triangleWidth
, edgeInsets
, totalHeight
properties before presenting the view controller. Otherwise it won't work as they cannot be modified at run time(yet?). You will have to recreate the pop over view controller if you want to change either of the 3 mentioed properties at run time after deallocation the previous instance :D.
Note: If you add a total height, the pop over will ignore the edge inset of the side on which the popover is displayed. For example if the popover appears on top, the top edge inset will be ignored.
You can present a pop over from any view of your choice and display a pop up with a text string. (Sort of like facebook tutorials). Have a look at the attached screenshot.
MRPopOverView *labelView = [[MRPopOverView alloc] init];
[labelView createInfoBelowView:sender withString:@"Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?Heyyyyyy! How ya doin?" andFont:nil];
[self.view addSubview:labelView];
@property (assign, nonatomic) CGFloat labelBorderWidth;
@property (strong, nonatomic) UIColor *labelBackgroundColor;
@property (strong, nonatomic) UIColor *labelTextColor;
@property (strong, nonatomic) UIColor *textBorderColor;
@property (assign, nonatomic) CGFloat triangleWidth;
Note: Set the triangleWidth
property before presenting the view controller. Otherwise it won't work.
Note: Similar to the view controller, there is a delegate to notify you when user dismisses the label called userDidDismissView
. Make your class conform to MRPopOverViewDelegate
This is similar to the previous way of implementation with only the difference that instead of passing a view to display a string, you can pass an array of dictionaries containing coordinates and text for each label.
MRPopOverView *labelView = [[MRPopOverView alloc] init];
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"How ya doin?Heyyyyyy!",@"text",@(sender.center.x),@"xCoordinate", @(sender.center.y), @"yCoordinate",sender.superview,@"viewToBeMadeIn",nil];
NSArray *array = [[NSArray alloc] initWithObjects:dict, nil];
[labelView createInfoWithPointsAndTextDictionaryArray:array andFont:nil];
[self.view addSubview:labelView];
Note: The additional properties are same as above.