我想在MFMailComposer Controller中设置导航项目的图像(发送按钮),然后我编写代码。
[picker.navigationItem.rightBarButtonItem setImage:[UIImage imageNamed:@“sendbutton.png”]];
但它并没有改变它。我改变becoz我的发送按钮使用此代码不工作..
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];
但我的取消按钮有代码
UIBarButtonItem *cancelBtn= picker.navigationBar.topItem.leftBarButtonItem;
UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
btn1.frame = CGRectMake(20, 2, 60, 30);
[btn1 setImage:[UIImage imageNamed:@"btn_tellAFriend_cancel@2x.png"]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];
工作正常
答案 0 :(得分:1)
MFMailComposeViewController发送按钮无法修改,不应根据苹果
进行更改你唯一能做的就是更改MFMailComposeViewController导航栏色调颜色,这也会改变发送按钮的颜色
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
[[picker navigationBar] setTintColor:[UIColor redColor]];
答案 1 :(得分:0)
试试此代码。
[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];