-(void)clickAdrress:(UIButton *)sender{
NSLog(@"点击地址弹出控制器");
_addressPopone = [addressPopViewController new];
_addressPopone.view.backgroundColor = [UIColor clearColor];
_addressPopone.preferredContentSize = CGSizeMake(self.view.frame.size.width-10-10, self.view.frame.size.height/2);
_addressPopone.modalPresentationStyle = UIModalPresentationPopover;
_addressPopone.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
_redView = [[UIView alloc]init];
_redView.frame = _addressPopone.view.frame;
_redView.backgroundColor = [UIColor clearColor];
UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(40, 40, 40, 40)];
btn.backgroundColor = [UIColor blueColor];
[btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
[_redView addSubview:btn];
[_addressPopone.view addSubview:_redView];
self.popover = _addressPopone.popoverPresentationController;//初始化一个
self.popover.delegate = self;
self.popover.sourceView = self.addressBtn;
self.popover.sourceRect = self.addressBtn.bounds;
//self.popover.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
self.popover.backgroundColor = [UIColor clearColor];
[self presentViewController:_addressPopone animated:YES completion:nil];
}
-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
return UIModalPresentationNone;
}
-(void)clickBtn:(UIButton *)sender{
[self dismissViewControllerAnimated:YES completion:nil];
//
addressPopViewController *addressPop = [[addressPopViewController alloc]init];
addressPop.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:addressPop animated:YES completion:nil];
}
-(void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController{
[self dismissViewControllerAnimated:YES completion:nil];
}