Отобразить clearColor UIViewController поверх UIViewController

у меня естьUIViewController смотреть как подпредставление / модал поверх другогоUIViewController представление, такое как то, что подпредставление / модал должно быть прозрачным, и любые компоненты, добавленные к подпредставлению, должны быть видимыми. Проблема в том, что у меня есть подпредставление показывает черный фон вместо того, чтобы иметь clearColor. Я пытаюсь сделатьUIView в качестве прозрачного цвета не черный фон. Кто-нибудь знает, что с ним не так? Любое предложение приветствуется.

FirstViewController.m

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];

[vc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:vc animated:NO];  

SecondViewController.m

- (void)viewDidLoad 
{
     [super viewDidLoad];
     self.view.opaque = YES;
     self.view.backgroundColor = [UIColor clearColor];
}

RESOLVED: Я исправил проблемы. Это работает так хорошо для iPhone и iPad. Модальный View Controller без черного фона просто прозрачный / прозрачный. Единственное что мне нужно поменять это я заменилUIModalPresentationFullScreen вUIModalPresentationCurrentContext, Как это просто!

FirstViewController.m

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:NO completion:nil];

NOTICE: Если вы используетеmodalPresentationStyle собственностьюnavigationController:

FirstViewController.m

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
vc.view.backgroundColor = [UIColor clearColor];
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:NO completion:nil];

NOTICE: The bad news is that the above solution doesn't work on iOS 7. The good news is that I fixed the issue for iOS7! I asked somebody for help and here is what he said:

When presenting a view controller modally, iOS removes the view controllers underneath it from the view hierarchy for the duration it is presented. While the view of your modally presented view controller is transparent, there is nothing underneath it except the app window, which is black. iOS 7 introduced a new modal presentation style, UIModalPresentationCustom, that causes iOS not to remove the views underneath the presented view controller. However, in order to use this modal presentation style, you must provide your own transition delegate to handle the presentation and dismiss animations. This is outlined in the 'Custom Transitions Using View Controllers' talk from WWDC 2013 https://developer.apple.com/wwdc/videos/?id=218 который также описывает, как реализовать свой собственный делегат перехода.

Вы можете увидеть мое решение для вышеупомянутой проблемы в iOS7:https://github.com/hightech/iOS-7-Custom-ModalViewController-Transitions

Ответы на вопрос(16)

Ваш ответ на вопрос