Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of MFMailComposeViewController texts and button images?

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

like image 724
Reconquistador Avatar asked Apr 21 '15 11:04

Reconquistador


2 Answers

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

like image 168
Bisca Avatar answered Oct 30 '22 18:10

Bisca


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.

like image 1
desmond_yy Avatar answered Oct 30 '22 18:10

desmond_yy