Reputation: 97
I want to set image of navigation item (send button) in MFMailComposer Controller,and i write code this..
[picker.navigationItem.rightBarButtonItem setImage:[UIImage imageNamed:@"sendbutton.png"]];
but it's not change it.I change becoz my send button not working using this code..
UIBarButtonItem *sendBtn=picker.navigationBar.topItem.rightBarButtonItem;
UIButton *btn2=[UIButton buttonWithType:UIButtonTypeCustom];
btn2.frame=CGRectMake(280, 2, 55, 30);
[btn2 setImage:[UIImage imageNamed:@"images (2).jpeg"]forState:UIControlStateNormal];
btn2.backgroundColor=[UIColor clearColor];
[btn2 addTarget:sendBtn.target action:sendBtn.action forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *btnTemp2=[[UIBarButtonItem alloc]initWithCustomView:btn2];
[[[[picker viewControllers]lastObject] navigationItem] setRightBarButtonItem:btnTemp2];
But my cancel button have code
UIBarButtonItem *cancelBtn= picker.navigationBar.topItem.leftBarButtonItem;
UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
btn1.frame = CGRectMake(20, 2, 60, 30);
[btn1 setImage:[UIImage imageNamed:@"[email protected]"]forState:UIControlStateNormal];
btn1.backgroundColor=[UIColor clearColor];
[btn1 addTarget:cancelBtn.target action:cancelBtn.action forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *btnTemp = [[UIBarButtonItem alloc] initWithCustomView:btn1];
[[[[picker viewControllers] lastObject] navigationItem] setLeftBarButtonItem:btnTemp];
[btnTemp release];
It work fine
Upvotes: 0
Views: 748
Reputation: 1965
MFMailComposeViewController send button cannot be modified and should not be changed according to apple
The only thing you can do is change MFMailComposeViewController navigation bar tint color which will also change send button color
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
[[picker navigationBar] setTintColor:[UIColor redColor]];
Upvotes: 1
Reputation: 322
Try this Code.
[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navbar_logo.png"]];
[imageView sizeToFit];
imageView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
UIBarButtonItem *loadingView = [[UIBarButtonItem alloc] initWithCustomView:imageView];
loadingView.target = self;
self.navigationItem.rightBarButtonItem = loadingView;
[imageView release];
[loadingView release];
Upvotes: 0