how to open a new uiview like a popup?

微笑、不失礼 提交于 2019-12-17 19:55:16

问题


i have a tabbar app. there is a button in one of tab. i want to open a new uiviewcontroller by animation like popup when i press the button. popupviewcontroller has a uiwebview. i want to show some web pages in popup view. i designed the popupview in IB.

how can i open my popupviewcontroller with animation like FBConnect. FBconnect opens the login dialog view with animation like a popup.


回答1:


You won't be able to open like a popup a UIViewController.

For that you will have to use a simple UIView

Add the UIview (popup shape like) to your current view.

- (void) initPopUpView {
  popup.alpha = 0;
  popup.frame = CGRectMake (160, 240, 0, 0);
  [self.view addSubview:popup];
}

- (void) animatePopUpShow {
  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:0.3];
  [UIView setAnimationDelegate:self];
  [UIView setAnimationWillStartSelector:@selector(initPopUpView)];

  popup.alpha = 1;
  popup.frame = CGRectMake (20, 40, 300, 400);

  [UIView commitAnimations];
}



回答2:


Yup you can open look like popup window u just use this code and run it.. its open very slowly depends on your time given...

Might be helpful

(void)popup
{
    UIView *AView1=[[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2,self.view.frame.size.height/2, 0, 0)];
    [AView1 setBackgroundColor:[UIColor redColor]];
    [UIView animateWithDuration:2.5 animations:^{AView1.frame = CGRectMake(35, 10, self.view.frame.size.width-70, self.view.frame.size.height-100);}];
}


来源:https://stackoverflow.com/questions/3419053/how-to-open-a-new-uiview-like-a-popup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!