//1. 创建popVC
UIViewController*contentVC = [[UIViewControlleralloc]init];
contentVC.view.backgroundColor= [UIColorredColor];
//2. 设置popVC的尺寸
contentVC.preferredContentSize=CGSizeMake(300,300);
//3. 设置popVC为popOver
contentVC.modalPresentationStyle=UIModalPresentationPopover;
//4. 设置箭头方向
contentVC.popoverPresentationController.permittedArrowDirections=UIPopoverArrowDirectionUp;
//5. 设置参考系
contentVC.popoverPresentationController.sourceView=self.view;
//6. 设置箭头指向的对象
contentVC.popoverPresentationController.sourceRect=self.btn.frame;
//7. 展现popVC
[selfpresentViewController:contentVCanimated:YEScompletion:NULL];
网友评论