UIPopoverPresentationController是个什么?
我理解中的UIPopoverPresentationController是个弹出的控件,与UIAlertController类似,但又不同。UIPopoverPresentationController是iOS8以后新增的,是UIViewController的属性。使用的的时候,需要创建的是UIViewController。
先看一段代码:
UIViewController *functionListVC = [[UIViewController alloc] init];
functionListVC.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *pover = functionListVC.popoverPresentationController;
pover.delegate = self;
pover.sourceView = testButton;
pover.sourceRect = testButton.bounds;
pover.backgroundColor = [UIColor colorWithRed:63/255.0 green:66/255.0 blue:75/255.0 alpha:1.000];
pover.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self presentViewController:functionListVC animated:YES completion:nil];
sourceView是指弹出时所参照的视图,与弹框的位置有关。