美文网首页
UIPopoverPresentationController

UIPopoverPresentationController

作者: 林希品 | 来源:发表于2021-11-26 16:42 被阅读0次
image.png
- (void)buttonClick:(UIButton *)sender{
    self.buttonPopVC = [[PopoverViewController alloc] init];   //普通控制器 viewController
    self.buttonPopVC.modalPresentationStyle = UIModalPresentationPopover;
    self.buttonPopVC.popoverPresentationController.sourceView = _button;  //rect参数是以view的左上角为坐标原点(0,0)
    self.buttonPopVC.popoverPresentationController.sourceRect = _button.bounds; //指定箭头所指区域的矩形框范围(位置和尺寸),以view的左上角为坐标原点
    self.buttonPopVC.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp; //箭头方向
    self.buttonPopVC.popoverPresentationController.delegate = self;
    [self presentViewController:self.buttonPopVC animated:YES completion:nil];
}

相关文章

网友评论

      本文标题:UIPopoverPresentationController

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