1.效果如下:
- 实现代码如下:
- (IBAction)btnClick:(UIButton *)sender {
MenuController *menu = [[MenuController alloc] initWithStyle:UITableViewStylePlain];
menu.modalPresentationStyle = UIModalPresentationPopover;
menu.preferredContentSize = CGSizeMake(150, 200);
UIPopoverPresentationController *p = menu.popoverPresentationController;
p.delegate = self;
p.sourceView = sender;
p.sourceRect = CGRectMake(0, 0, sender.frame.size.width, sender.frame.size.height);
[self presentViewController:menu animated:YES completion:nil];
}
#pragma mark - UIPopoverPresentationControllerDelegate
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
}