2013-03-20 29 views
0

我在我的應用程序中使用mfmessagecomposeviewcontroller發送短信。我的問題是,當查看當前的導航標題和按鈕的標題字體與應用字體不一樣。我想改變這個標題的字體。我有這麼多嘗試設置它,但我不能做到這一點..請給我一些例子或想法,我該怎麼做。我們可以更改MFmessagecomposeViewcontroller導航標題字體

我的代碼是

if([MFMessageComposeViewController canSendText]) 
     { 
      MFMessageComposeViewController *messageController=[[MFMessageComposeViewController alloc] init]; 
      messageController.messageComposeDelegate=self; 
      messageController.topViewController.navigationController.navigationBar.titleTextAttributes=[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Tijjxdydjmmdouybfrertnsaenp" size:21],UITextAttributeFont, nil]; 
      [messageController.topViewController.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Tijjxdydjmmdouybfrertnsaenp" size:21],UITextAttributeFont, nil] forState:UIControlStateNormal]; 
      [email protected]"Hey, you should get this app, it allows us to create and share recipes with each other, & it also has a 7 day meal plan with grocery list. https://itunes.apple.com/us/app/fit-chick-meal-plan-recipe/id576329137?ls=1&mt=8 "; 
      [email protected]"SMS"; 
      [messageController setModalTransitionStyle:UIModalPresentationPageSheet]; 
      [self presentViewController:messageController animated:YES completion:^(void){}]; 
     } 

-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result 
{ 
    switch (result) { 
     case MessageComposeResultSent: 
     { 
      [AppUtility displayAlertForTitle:@"Message Status" forMessage:@"Message has been sent successfully" forDelegate:nil forCancelButton:@"Ok"]; 
     } 
      break; 
     case MessageComposeResultCancelled: 
     { 
      NSLog(@"Message sending cancelled"); 
     } 
      break; 
     case MessageComposeResultFailed: 
     { 
      [AppUtility displayAlertForTitle:@"Message Status" forMessage:@"Message sending failed" forDelegate:nil forCancelButton:@"Ok"]; 
     } 
      break; 
     default: 
     { 
      [AppUtility displayAlertForTitle:@"Message Status" forMessage:@"Message sending failed" forDelegate:nil forCancelButton:@"Ok"]; 
     } 
      break; 
    } 
    [self dismissViewControllerAnimated:YES completion:nil]; 

} 

下面感謝提前。

回答

1

使用此:

messageController.topViewController.navigationItem.titleView = yourLabelHereWithANyFont; 

在它創建UILabel和改變字體和提供titleView

+0

感謝您的回覆王子,但我們不能改變它與controller.navigationbar.titletextAttribute = dictionary; – 2013-03-20 06:13:21

+0

是的,你也可以使用titletextAttribute – 2013-03-20 06:16:18

+0

做到這一點對不起現在這個問題發生在第一個應用程序與此消息'NSInvalidArgumentException'墜毀,原因:'應用程序試圖目標 – 2013-03-20 06:22:48