Bug 53352 - XF/iOS's Global Tint color does not effect to DisplayAlert nor DisplayActionSheet.
Summary: XF/iOS's Global Tint color does not effect to DisplayAlert nor DisplayActionS...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.3.4
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-03-15 12:28 UTC by Bright Lee
Modified: 2017-03-28 09:05 UTC (History)
5 users (show)

Tags: bug, ios, tintcolor, alert, actionsheet
Is this bug a regression?: Yes
Last known good build: 2.3.3.193


Attachments
sample project (31.16 KB, application/zip)
2017-03-15 12:28 UTC, Bright Lee
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Bright Lee 2017-03-15 12:28:59 UTC
Created attachment 20348 [details]
sample project

After I updated to XF 2.3.4-pre5

XF/iOS's Global Tint color does not effect to DisplayAlert nor DisplayActionSheet.
So, my text color of DisplayAlert and DisplayActionSheet is set as blue color (which is default tint color).

It worked fine on XF2.3.3.193 with same Xamarin.iOS version which is latest.(Version: 10.4.0.123)

below code is my code that changes global tint color in AppDelegate.cs
        ...
        LoadApplication (new App ());

        bool result = base.FinishedLaunching(app, options);

        UIApplication.SharedApplication.KeyWindow.TintColor = AppConstants.GlobalColor.ToUIColor();
        ...


Below code does not work either.

            UIAlertView.Appearance.TintColor = mycolor;
            UIActionSheet.Appearance.TintColor = mycolor;


attached sample project reproduces this bug.
Comment 1 Jimmy [MSFT] 2017-03-15 16:58:03 UTC
I was able to reproduce this issue with the attached repro project and Forms 2.3.4-pre5. It is ignoring the UIApplication.SharedApplication.KeyWindow.TintColor set in AppDelegate and using the default color instead.

This does appear to be a regression as the issue does not occur with Forms 2.3.3.193.

### Regression Status
Forms 2.3.4-pre5    BAD
Forms 2.3.3.193     GOOD
Comment 2 Rui Marinho 2017-03-20 15:48:39 UTC
https://github.com/xamarin/Xamarin.Forms/pull/823
Comment 3 Rui Marinho 2017-03-20 15:49:35 UTC
Btw setting KeyWindow doesn't seem the correct way, maybe try UIWindow.Appearence.TintColor
Comment 4 E.Z. Hart [MSFT] 2017-03-20 18:17:17 UTC
In order to address some other problems in alerts and action sheets, DisplayAlert and DisplayActionSheet no longer use UIAlertView and UIActionSheet (both of which are deprecated as of iOS 8); instead they now use UIAlertController. They also display in a new UIWindow, which means they do not inherit the main application window's settings.

For globally setting a tint color which also applies to alerts and action sheets, you can use something like:

`UIView.Appearance.TintColor = myColor;`

If you only want to set the colors for alerts and action sheets specifically, you can use the `AppearanceWhenContainedIn` method, something like this:

`UIView.AppearanceWhenContainedIn(typeof(UIAlertController)).TintColor = UIColor.Green;`
Comment 5 Bright Lee 2017-03-28 09:05:17 UTC
Hi E.Z. Hart. 

I understood. 

but UIView.Appearance.TintColor = AppConstants.GlobalColor.ToUIColor(); is unusable because if I do that, it changes UITabbar's unseleced color as well, which is not correct behavior. 

I changed each UI type separately. like below.

	UITabBar.Appearance.TintColor = AppConstants.GlobalColor.ToUIColor();
	UITextField.Appearance.TintColor = AppConstants.GlobalColor.ToUIColor();
	UIView.AppearanceWhenContainedIn(typeof(UIAlertController)).TintColor = AppConstants.GlobalColor.ToUIColor();

It's working well so far.