IOS--弹出viewController窗口 自定义底层框架--

//通过点击主页面按钮弹出settingPageController窗口 主页面是self.view
//这是主页面button的点击实现函数
-(IBAction)button_touch:(id)sender{
    //settingPage是一个newViewController 在此进行初始化
    settingPage*setting_page=[[settingPage alloc] initWithNibName:@"settingPage" bundle:nil];
    //设定settingPageViewController的rootViewController是UINavigationController(可以任意设置)
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:setting_page];
    //设置leftBarButton为完成按钮
    UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"完成"
                                                                  style:UIBarButtonItemStyleDone
                                                                 target:self action:@selector(achieving:)];
    setting_page.navigationItem.leftBarButtonItem = barButton;
    nav.modalInPopover = NO;
    nav.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:nav animated:YES];
    nav.view.superview.center = CGPointMake(500, 400);//设置中点坐标
    nav.view.superview.frame = CGRectMake(300, 200, 500,500);//it's important to do this after presentModalViewController
    
    [setting_page.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"toubar.png"] forBarMetrics:UIBarMetricsDefault];
    setting_page.navigationItem.title=@"设置";
    [setting_page release];
    [barButton release];
    [nav release];
    
}
//完成返回键
-(IBAction)achieving:(id)sender{
    [self dismissModalViewControllerAnimated:YES];
}

你可能感兴趣的:(弹出窗口,弹出窗体,PopoverView)