Jon*_*hih 67 uiactivityviewcontroller ios7
我正在使用UIActivityViewController在iOS7中共享项目.当我点击"邮件"选项时,它会弹出邮件编辑器,但导航栏上的"取消"和"发送"按钮以及导航栏本身都是蓝色的,这使得它很难阅读,所以我想改变它们的颜色.它在iOS6中工作,但在iOS7中不工作.
我试过了
[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, nil] forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
哪个适用于iOS6,我试过了
[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
Run Code Online (Sandbox Code Playgroud)
这会导致颜色在第一次运行应用程序时闪烁红色,然后立即切换回蓝色.
Ale*_*lex 76
管理时可以更改发送和取消按钮的文本颜色,这些按钮UINavigationBar位于MFMailComposerViewController(发送和取消)和MFMessageComposeViewController(仅取消)中,当显示时UIActivityViewController.
使用UIActivityViewController,点击Message或Mail:

您会注意到" 发送"和" 取消"按钮的默认文本颜色为蓝色:

为了更改它,在AppDelegate.m类中,在didFinishLaunchingWithOptions方法中,插入以下行:
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];
Run Code Online (Sandbox Code Playgroud)
这导致:

您还可以使用其他颜色,例如:
[UIColor purpleColor];

[UIColor greenColor];

我是如何测试的?我注意到这个解决方案适用于以下方面:
使用以下方法测试时无法正常工作:
因此它应该是安全的,因为我相信实际设备上的行为比iOS模拟器中的行为更重要.如果有人知道为什么它在iOS 7.0模拟器中不起作用,我想知道.:)
maz*_*ati 25
UIActivityViewController中的条形色调和状态栏颜色.Swift 3解决方案:
extension MFMailComposeViewController {
override open func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
}
open override func viewDidLoad() {
super.viewDidLoad()
navigationBar.isTranslucent = false
navigationBar.isOpaque = false
navigationBar.barTintColor = UIColor.white
navigationBar.tintColor = UIColor.white
}
}
Run Code Online (Sandbox Code Playgroud)
这是适用于iOS 7.1的功能.
对UIActivityViewController进行子类化并覆盖以下方法:
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
{
viewControllerToPresent.view.tintColor = [UIColor whiteColor];
[super presentViewController:viewControllerToPresent animated:flag completion:^{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
if (completion) {
completion();
}
}];
}
Run Code Online (Sandbox Code Playgroud)
这将使按钮变白并且状态栏变为白色.
好吧,我们无法改变苹果代码中 UI 的现状是有原因的。主要是因为它是苹果的。它们不允许您以任何方式编辑 MFMailComposerViewController 中 UI 的外观。如果有办法,那么我对此一无所知,但我从未见过任何方法可以做到这一点。MFMailComposeViewController 不支持外观属性,因为它是在 iOS 3.0 中创建的,直到 iOS 5.0 才出现外观
这是 MFMailComposeViewController 苹果文档的链接:MFMailComposeViewController
希望这可以帮助!
| 归档时间: |
|
| 查看次数: |
18472 次 |
| 最近记录: |