0

What is the best way to use custom background images for the "cancel" and "send" buttons (barbuttonitems) in MFMailComposeViewController?

A/N: I know about the note on Apple's website about not changing interfact, but I need to do this for consistency throughout the application.

Dhara
  • 4,093
  • 2
  • 36
  • 69
user754905
  • 1,799
  • 3
  • 21
  • 29

2 Answers2

0

You can customize the look of the navigationbar, cancel and send button, through app delegate.

Try this code:

UIImage*resizedImage = [[UIImage imageNamed:@"navbar1"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 12, 12, 10)];
id navbar =[UINavigationBar appearance];
id barbutton =[UIBarButtonItem appearance];

//this customises the navigation bar 
[navbar setBackgroundImage:resizedImage forBarMetrics:UIBarMetricsDefault];
UIImage *backButton = [[UIImage imageNamed:@"blueButton"]  resizableImageWithCapInsets:UIEdgeInsetsMake(10 , 18, 10 , 18)];

// this customises the back bar button item in the navigation bar
[barbutton setBackButtonBackgroundImage:backButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];


// this for other bar button items 
[barbutton setBackgroundImage:backButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Michael Celey
  • 12,645
  • 6
  • 57
  • 62
  • This works with one exception: It seems MFMailComposeViewController ignores the resizingMode parameter: `[[UIBarButtonItem appearance] setBackgroundImage:[[UIImage imageNamed:@"btn-main.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(4.0, 4.0, 4.0, 4.0) resizingMode:UIImageResizingModeStretch] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];` – gklka Jun 09 '13 at 12:29
0

You can always send the email in the background and control how the form and email buttons look. Take a look at this post and the answer on how to do that.

Locking the Fields in MFMailComposeViewController

Community
  • 1
  • 1
Louie
  • 5,920
  • 5
  • 31
  • 45