How to change color of MFMailComposeViewController texts and button images?
Asked Answered
V

2

9

iOS uses standard (blue) tint color for all colored texts in MFMailComposeViewController. This is not good for me, as customer wants his company colors in app. How to change their color to orange?

I am asking specifically about colors of button icons (add image and bell image) and texts containing mail addresses. I already have navigation bar colors changed. In documentation, there is written:

The view hierarchy of this class is private and you must not modify it. You can, however, customize the appearance of an instance by using the UIAppearance protocol.

I have tried to use it, but it is not working (I might doing it a wrong way, as I do not know UIAppearance). This is what I have tried:

        [[UIButton appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

        [[UILabel appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setTextColor:[UIColor orangeColor]];

enter image description here

Vent answered 21/4, 2015 at 11:59 Comment(6)
Use tintColor like this, mailComposerViewController.view.tintColor = [UIColor whiteColor]Preiser
Property tintColor is not available for MFMailComposeViewControllerVent
Sorry I meant view, please look at the edit above.Preiser
Color has not been changedVent
Do you want to change the text color inside navigation bar or just inside the view ?Preiser
I have added picture to make it clearVent
H
1

As Apple says: https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/index.html

The view hierarchy of this class is private and you must not modify it. You can, however, customize the appearance of an instance by using the UIAppearance protocol.

Anyway, you can check this post: Customizing automatic MFMailComposeViewController opened from UITextView

Hightower answered 21/4, 2015 at 12:48 Comment(3)
In that post, there is only information how to change color of texts in navigation bar, which is something I have already did.Vent
Yes, you are right. Have you tried? [[UINavigationBar appearance] setTintColor:[UIColor redColor]];Hightower
I do not need to change appearance of UINavigationBar, as it is already changed.Vent
C
1

I got this problem too. Just use:

UIView.appearance().tintColor = .orange

This works fine but there is a flaw. The recipients text will change back to system tintColor(blue) when editing.

Cogswell answered 31/3, 2019 at 5:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.