2012-06-12 40 views
13

Tôi không gặp vấn đề gì về màu thay đổi của tiêu đề điều hướng chính trên một viewController bình thường nhưng trên MFMailComposeViewController, điều đó là không thể. Tôi có thể thay đổi màu sắc của các nút (hủy và gửi), tôi có thể đặt nền của thanh điều hướng nhưng không thể thay đổi màu của tiêu đề. Tôi không muốn thiết lập một tiêu đề mới (rõ ràng, nó không cho phép bởi Apple), tôi chỉ muốn thay đổi màu sắc:. '(Thay đổi màu tiêu đề chính của điều hướng trong MFMailComposeViewController

Xin hãy giúp tôi Cảm ơn

+0

Tham khảo liên kết này: http://stackoverflow.com/questions/1634417/changing-mfmailcomposeviewcontrollers-toolbar-color – Dee

Trả lời

16
NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys: 
              [UIColor whiteColor],UITextAttributeTextColor, 
              [UIColor blackColor], UITextAttributeTextShadowColor, 
              [NSValue valueWithUIOffset:UIOffsetMake(-1, 0)], UITextAttributeTextShadowOffset, nil]; 

[[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes]; 

Hoặc

navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor yellowColor] forKey:UITextAttributeTextColor]; 

Hy vọng công việc của mình cho bạn ..

10
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init]; 
    picker.mailComposeDelegate = self; 
    [[picker navigationBar] setTintColor:[UIColor blackColor]]; 
+0

Nó không phải là những gì tôi tìm kiếm, ở đây bạn thay đổi màu sắc của thanh điều hướng (Tôi đã có nền tảng cho đó), tôi muốn thay đổi màu của titleview – user1451163

+0

nhưng nhờ phải thử ^^ – user1451163

0

đối với màu sắc khác ngoài đen, chơi xung quanh với mã này :

MFMailComposeViewController *mailController = [MFMailComposeViewController new]; 

      [mailController.navigationBar setTintColor:[UIColor colorWithHue:240.0f/359.0f 
                    saturation:85.0f/100.0f 
                    brightness:60.0f/100.0f 
                     alpha:0.0f]]; 
13

Đây là câu trả lời đúng cho iOS 7, 8, 9, và 10:

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
picker.mailComposeDelegate = self; 
[[picker navigationBar] setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor blackColor] forKey:NSForegroundColorAttributeName]]; 

Đây là lý do tại sao:

Vui lòng cung đánh dấu câu trả lời ở trên (bởi Mani) tham chiếu [UINavigationBar appearance] là không chính xác vì nó cũng sẽ thay đổi màu của tiêu đề trong số UINavigationBar cũng xuất hiện là MFMailComposeViewController, đó là một hiệu ứng mà tôi không muốn. Bạn cần phải cụ thể nhận được NavBar của người chọn như mã của tôi.

Đặt tintColor cũng không chính xác như iOS 7 (câu trả lời khác của Mani) vì nó đặt màu của các nút chứ không phải tiêu đề.

Đồng thời, UITextAttributeTextColor hiện không còn được dùng nữa, vui lòng sử dụng NSForegroundColorAttributeName.

Các vấn đề liên quan