How to change background color of MFMailComposeViewController?

How to change background color of MFMailComposeViewController? I tried to add

mailController.view.backgroundColor = [UIColor redColor];

but the color is still white. Please, help.

+4
source share
1 answer

I began to debug the hierarchy MFMailComposeViewController. Here is my code.

MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];

[self presentViewController:mailComposeViewController animated:YES completion:^{
    UIViewController* mailViewController = [mailComposeViewController.topViewController.childViewControllers firstObject];
    UIView *mailView = [mailViewController.view.subviews firstObject];
    CALayer *mailLayer = mailView.layer;
    mailLayer.opacity = 0.5f;

    UIView *backgroundView = [[UIView alloc] initWithFrame:mailView.bounds];
    backgroundView.backgroundColor = [UIColor redColor];
    [mailViewController.view insertSubview:backgroundView atIndex:0];
}];

I found that MFMailComposeViewControllerbeing a kind of UINavigationControllerhas a top view controller that has a child view controller. In the view of the child view controller, there is a subview. This view contains content.

, . , . . alpha , , .

, mailLayer, CALayerHost, ; - . , , .

, , . .

+1

Source: https://habr.com/ru/post/1599471/


All Articles