MFMailComposeViewController 中的自定义 UINavigationBar 背景
我需要在 MFMailComposeViewController
中为 UINavigationBar
使用自定义背景。以前,我在 UINavigationBar
上使用一个类别来在我的应用程序中实现此目的,但 Apple 特别要求您不要这样做。此外,这可能会或可能不会在当前处于保密协议下的 iOS 未来版本中起作用。
我现在使用 UINavigationBar
的子类来实现我在应用程序其余部分中所追求的外观,但我看不到任何将其与 MFMailComposeViewController
一起使用的方法>。有什么想法吗?
注意:我知道在未来版本的 iOS 中执行此操作的方法,但这需要针对 SDK 的当前版本 (4.3) 进行构建。
I have a need to use a custom background for the UINavigationBar
in a MFMailComposeViewController
. Previously I was using a category on UINavigationBar
to achieve this throughout my app, but Apple specifically requests that you do not do this. Additionally this may or may not work in future versions of iOS that are currently under NDA.
I am now using a subclass of UINavigationBar
to achieve the look I'm after in the rest of the app, but I can't see any way to use this with the MFMailComposeViewController
. Any ideas?
Note: I'm aware of methods to do this in a future version of iOS, but this needs to be built against a current version (4.3) of the SDK.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我刚刚遇到过这个问题——您可以使用
object_setClass
动态注入视图控制器使用的类。I just ran across this -- you can dynamically inject the class a view controller uses using
object_setClass
.您可以使用下面的代码使用自定义视图来自定义导航栏的 titleView。扩展这个想法,您也许能够调整 titleView 的大小以覆盖整个导航栏,并在其中使用自定义背景来模拟自定义导航栏背景。
我能想到的唯一可能的棘手部分是您需要确保 titleView 位于工具栏中的按钮后面。
获得 MFMailComposerViewController 参考后,以下是自定义 titleView 的代码:
You can customize the nav bar's titleView with a custom view using the code below. Expanding upon this idea, you may be able to resize the titleView to cover the entire navigation bar and use a custom background in that to simulate a custom navbar background.
The only possible sticky part I can think of is that you need to make sure the titleView sits behind the buttons in the toolbar.
Once you have your MFMailComposerViewController reference, here is the code to customize the titleView:
邮件撰写界面本身不可自定义,并且不得由您的应用程序修改。
检查苹果参考以获取更多信息...
http ://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html
但我们可以自定义邮件上述答案给出的组成......
The mail composition interface itself is not customizable and must not be modified by your application.
check apple reference for more info...
http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html
but we can customizable the mail composition as given oin the above answer....
经过一些黑客和测试,仍然无法自定义按钮。但这是我可以通过设置邮件控制器的色调颜色得到的最接近的结果。
尝试通过
mailController.navigationBar.items
访问它们,它是一个栏项目数组。After some hacking and testing, still not manage to customize the button. But this is the closest I can get, by setting the tint color of mail controller.
Try accessing them through
mailController.navigationBar.items,
which is an array of the bar items.虽然更好地控制外观会很好,但我不认为有一个干净的方法。当你无法更改它时...隐藏它:
Although it would be nice to get more control over the appearance, I don't think there is a clean method. When you cant change it...hide it: