问题
I am using mfmessagecomposeviewcontroller in my app for sending sms. My problem is that when view present then the navigation title and button's title font not same to the appliction font. I want to change the font of this title. I have so much try to set it but i can not do it.. Please give me some example or idea about it that how can i do it.
My code is below
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];
messageController.body=@"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 ";
messageController.title=@"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];
}
thanks in advance.
回答1:
Use this:
messageController.topViewController.navigationItem.titleView = yourLabelHereWithANyFont;
Create a UILabel
and change font in it and provide to titleView
.
来源:https://stackoverflow.com/questions/15516303/can-we-change-mfmessagecomposeviewcontroller-navigtion-title-font