UIPresentationController

来源:互联网 发布:寄生虫推广软件 编辑:程序博客网 时间:2024/05/29 04:14

-(void)clickAdrress:(UIButton *)sender{

    NSLog(@"点击地址弹出控制器");

    _addressPopone = [addressPopViewControllernew];

    _addressPopone.view.backgroundColor = [UIColorclearColor];

    _addressPopone.preferredContentSize =CGSizeMake(self.view.frame.size.width-10-10,self.view.frame.size.height/2);

    _addressPopone.modalPresentationStyle =UIModalPresentationPopover;

    _addressPopone.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;

    _redView = [[UIViewalloc]init];

    _redView.frame =_addressPopone.view.frame;

    _redView.backgroundColor = [UIColorclearColor];

    UIButton *btn = [[UIButtonalloc]initWithFrame:CGRectMake(40,40, 40, 40)];

    btn.backgroundColor = [UIColorblueColor];

    [btn addTarget:selfaction:@selector(clickBtn:)forControlEvents:UIControlEventTouchUpInside];

    [_redViewaddSubview:btn];

    

    

    [_addressPopone.viewaddSubview:_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 = [UIColorclearColor];

    [selfpresentViewController:_addressPoponeanimated:YEScompletion:nil];

    

}

-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{

    returnUIModalPresentationNone;

    

}

-(void)clickBtn:(UIButton *)sender{

    

    [selfdismissViewControllerAnimated:YEScompletion:nil];

//    

    addressPopViewController *addressPop = [[addressPopViewControlleralloc]init];

    addressPop.modalPresentationStyle =UIModalPresentationFormSheet;

    [selfpresentViewController:addressPopanimated:YEScompletion:nil];

   

}


-(void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController{

    [selfdismissViewControllerAnimated:YEScompletion:nil];

}


0 0