【发布时间】:2011-07-06 18:39:08
【问题描述】:
为MFMailComposeViewController 中的“取消”和“发送”按钮 (barbuttonitems) 使用自定义背景图像的最佳方式是什么?
A/N:我知道 Apple 网站上关于不更改 interfact 的说明,但我需要这样做以确保整个应用程序的一致性。
【问题讨论】:
标签: ios ios4 mfmailcomposeviewcontroller
为MFMailComposeViewController 中的“取消”和“发送”按钮 (barbuttonitems) 使用自定义背景图像的最佳方式是什么?
A/N:我知道 Apple 网站上关于不更改 interfact 的说明,但我需要这样做以确保整个应用程序的一致性。
【问题讨论】:
标签: ios ios4 mfmailcomposeviewcontroller
您始终可以在后台发送电子邮件并控制表单和电子邮件按钮的外观。看看这篇文章以及如何做到这一点的答案。
【讨论】:
您可以通过应用委托自定义导航栏、取消和发送按钮的外观。
试试这个代码:
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];
【讨论】:
[[UIBarButtonItem appearance] setBackgroundImage:[[UIImage imageNamed:@"btn-main.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(4.0, 4.0, 4.0, 4.0) resizingMode:UIImageResizingModeStretch] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];