美文网首页
UIPopoverPresentationController

UIPopoverPresentationController

作者: August24 | 来源:发表于2017-01-10 08:51 被阅读54次

1.效果如下:

27.png
  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;
    }

相关文章

网友评论

      本文标题:UIPopoverPresentationController

      本文链接:https://www.haomeiwen.com/subject/ctlkbttx.html