簡體   English   中英

MFMailComposeViewController的自定義UINavigationBar出現問題

[英]Problem with custom UINavigationBar for MFMailComposeViewController

我已經使用UINavigationBar drawRect自定義了UINavigationBar,並且在我啟動MFMailComposeViewController之前,它工作正常,這給我帶來了麻煩,因為我無法為郵件類覆蓋UIBarButton,它創建了如下所示的尷尬視圖:

在此處輸入圖片說明

雖然我嘗試阻止MFMailComposeViewController並在下面生成用於將默認drawRect用於MFMailComposeViewController ,但更糟糕的是,它創建了一個黑色UIBar

在此處輸入圖片說明

編碼:

@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樣式(漸變藍色)

想知道我可以實現嗎? 提前致謝。

經過一些黑客和測試后,仍然無法自定義按鈕。 但這是我可以通過設置郵件控制器的着色顏色獲得的最接近的顏色。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM