2011-05-12 69 views
1

我已經使用UINavigationBar drawRect自定義我的UINavigationBar並且它工作正常,直到我啓動了MFMailComposeViewController,這給我帶來了麻煩,因爲我無法爲郵件類重寫UIBarButton,它創建了像如下:MFMailComposeViewController的自定義UINavigationBar問題

enter image description here

雖然我試圖阻止MFMailComposeViewController和使用默認的drawRect爲MFMailComposeViewController下面產生的代碼,它更糟糕的是創建一個黑色UIBar

enter image description here

驗證碼:

@implementation UINavigationBar (CustomImage) 
- (void)drawRect:(CGRect)rect { 


    //Prevent Mail Controller For Customizing NavigationBar 
    for (UIView* next = [self superview]; next; next = next.superview) { 
     UIResponder* nextResponder = [next nextResponder]; 
     if ([nextResponder isKindOfClass:[MFMailComposeViewController class]]) { 
      [super drawRect:rect]; 
      return; 
     } 
    } 

    UIImage *image = [UIImage imageNamed: @"titleBar.png"]; 
    [image drawInRect:CGRectMake(0, 0, 320, 44)]; 

} 
@end 

我想在這裏做的就是確保MFMailComposeViewController具有UINavigationBarUIButtonItem相同的風格。它可以是任何一種方式:

1)兩個UINavigationBarUIButtonItem已自定義背景

2)默認UINavigationBar風格(藍色漸變)

想知道我能做到這一點?提前致謝。

回答

1

經過一些黑客和測試,仍然沒有設法定製按鈕。但是,通過設置郵件控制器的色調,這是最接近的。

MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; 
mailController.mailComposeDelegate = self; 
mailController.navigationBar.tintColor = [UIColor brownColor]; 
+0

保存和取消按鈕是否啓用?在我的應用程序中,我還有一個自定義導航欄,當我嘗試使用MFMailComposeViewController撰寫郵件時,MFMailComposeViewController的導航欄被自定義導航欄覆蓋。所以取消和保存按鈕被禁用。如何使它們啓用?劑量任何人有任何想法? – Dee 2011-08-02 05:55:34

+0

我使用UINavigationBar的子類,當顯示郵件撰寫時,導航欄按鈕也被禁用。有沒有人有解決方案? – youshunei 2012-01-13 17:59:48