Search code examples
iosobjective-ciphoneipaduiactionsheet

semi transparent modalViewController


I've been researching this and it seems that the only way to do this is using UIActionSheet, the question is that my UIActionSheet only covers half of the screen, my code is:

MyViewController *myVC = [[myViewController alloc] init];
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"\n\n"
                                                           delegate:self
                                                  cancelButtonTitle:@"cancel"
                                             destructiveButtonTitle:@"done"
                                                  otherButtonTitles:nil];
[myActionSheet addSubview:myVC.view];
[myActionSheet showInView:currentView];
[myActionSheet release];

Also how do I then dismiss this UIActionSheet from my MyViewController? Is there any better solution than this? Here's a screenshot of what I mean by loading half of the screen:

screenshot

Here's a sample project to illustrate my issue.


Solution

  • UIActionSheet will increase or decrease it's height according to the number of UIButtons in it. What you can do is add another view above your view with your desired alpha. And remove it from subview and add in subview according to your requirement i.e. add subview when you are displaying actionsheet and remove when you are dismissing UIActionSheet. I hope this is relevant to your question and it will help you to solve your problem.