UIPopoverPresentationController

2021-11-26  本文已影响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];
}
上一篇下一篇

猜你喜欢

热点阅读