简体   繁体   English

UIActivityViewController:呈现的视图控制器的色彩

[英]UIActivityViewController: tint color of presented view controllers

In an app I use white as the main tint color. 在应用程序中,我使用白色作为主色调颜色。 If the user opens the UIActivityViewController , I set the tint color for the controller to the standard iOS blue. 如果用户打开UIActivityViewController ,我将控制器的色调颜色设置为标准iOS蓝色。 This works great for the activity view itself but when one wants to send a mail, the tint color is not blue but white again. 这对于活动视图本身很有用,但是当想要发送邮件时,色调颜色不是蓝色而是白色。

It would be great to have a way to set the tint color of the presented views. 有一种方法来设置呈现视图的色调颜色会很棒。 Is there one? 有吗?

Opening a MFMailComposeViewController and setting the tint color to blue also has an effect on the displayed UIActionSheet , not so if the MFMailComposeViewController is opened from within an UIActivityViewController . 打开MFMailComposeViewController并将色调颜色设置为蓝色也会对显示的UIActionSheet产生影响,如果从UIActivityViewController打开MFMailComposeViewController则不会这样。

See screenshots for clarification: http://i.imgur.com/OggykJF.png 有关说明,请参见屏幕截图: http//i.imgur.com/OggykJF.png

Edit: This is what I do for adding the tint color to the UIActivityViewController : 编辑:这是我为UIActivityViewController添加色调颜色所做的事情:

UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:activities];
activityController.view.tintColor = [UIColor blueColor];
[self presentViewController:activityController animated:YES completion:nil];`

The best what you can do is to set window's tint color to system blue or any tint color you wish on UIActivityViewController just before you present it and then change window's tint color back to original just before you dismiss it. 你可以做的最好的事情是在你呈现它之前将窗口的色调颜色设置为系统蓝色或你希望在UIActivityViewController上的任何色调颜色,然后在解除之前将窗口的色调颜色改回原始颜色。 That will work. 那可行。 This is how I do it: 我是这样做的:

UIApplication.shared.keyWindow?.tintColor = Styles.color.systemBlue

and then 然后

UIApplication.shared.keyWindow?.tintColor = Styles.color.tint

I had the same issue with the Cancel and Send buttons of the mail share controller being blue no matter what I tried. 我遇到了同样的问题,无论我尝试什么,邮件共享控制器的取消和发送按钮都是蓝色的。 I found that tweaking the navbar appearance wasn't doing the trick. 我发现调整导航栏外观并没有成功。 So I used this... 所以我用这个......

[[UIBarButtonItem appearance] setTintColor:tintColor];

I do this in an "Appearance" class I have that is called on load and sets all of the global appearances. 我在一个“外观”类中执行此操作,该类在加载时调用并设置所有全局外观。 For the navigation bar color, if you need to change that on the fly before presenting your share controller (UIActivityViewController), you can do it in the completion block when you first present your controller. 对于导航栏颜色,如果您需要在呈现共享控制器(UIActivityViewController)之前动态更改它,则可以在首次显示控制器时在完成块中执行此操作。 For example: 例如:

[self presentViewController:[self _shareController] animated:YES completion:^{
    [[UINavigationBar appearance] setBarTintColor:[UIColor yourNavBarColor]];
}];

I've not managed to get this to work at all, but have you considered the alternative - leaving the text white and changing the navbar background colour so they show up, eg with: 我根本没有设法让它工作,但是你考虑过替代方案 - 将文本保留为白色并更改导航栏背景颜色,以便它们显示出来,例如:

    UINavigationBar.appearance().backgroundColor = .black

This seems to work for the buttons on the navbar for the Mail and Twitter sharing screens. 这似乎适用于Mail和Twitter共享屏幕的导航栏上的按钮。

Set the tintColor on your UIActivityViewController after initializing but before presenting. 在初始化之后但在呈现之前,在UIActivityViewController上设置tintColor。

UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:activities];

//Set the tint color on just the activity controller as needed here before presenting
[activityController.view setTintColor:[UIColor blueColor]];

[self presentViewController:activityController animated:YES completion:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更改 UIActivityViewController 中 UIBarButtonItems 的色调颜色 - Changing tint color of UIBarButtonItems in UIActivityViewController 呈现的UINavigationController色彩不变 - Presented UINavigationController tint color not changing 所有呈现的视图控制器都不会被解雇 - All the presented view controllers are not dismissed 视图控制器显示不正确 - View Controllers not being presented correctly Swift:展示了两个视图控制器 - Swift: Two View Controllers presented 更改从UIActivityViewController打开的模式视图控制器的状态栏文本颜色 - Change status bar text color of modal view controllers opening from a UIActivityViewController 从UIActivityViewController中选择时,MessageComposer的NavigationBar和BarButtonItem颜色更改 - NavigationBar & BarButtonItem color change for MessageComposer presented on choosing from UIActivityViewController 如何在ios 13中设置下面呈现的视图控制器的系统背景颜色 - How to set the system background color below presented view controllers in ios 13 无法通过显示的视图控制器访问TopView - TopView is not accessible from presented view controllers 在iOS 8中的呈现视图控制器中,界面方向不正确 - interface orientation not correct in presented view controllers in iOS 8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM