如何更改iOS应用程序的Xamarin形式的全局色调颜色?

时间:2016-03-05 14:29:02

标签: c# ios xamarin xamarin.forms

如何在Xamarin表单项目(C#)中更改iOS应用的全局色调颜色?

2 个答案:

答案 0 :(得分:1)

全局iOS色调颜色可以在UIApplication.KeyWindow可用时设置,最早在应用程序完成启动后显示:

using Foundation;
using UIKit;

namespace MyApp.iOS
{
    [Register("AppDelegate")]
    public class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());
            var result = base.FinishedLaunching(uiApplication, launchOptions);

            uiApplication.KeyWindow.TintColor = UIColor.Blue;

            return result; 
        }
    }
}

答案 1 :(得分:-1)

在Xamarin.iOS Project中的应用程序完成启动方法中添加以下代码。

Boolean result = base.FinishedLaunching(app, options);
UIApplication.SharedApplication.KeyWindow.TintColor = UIColor.Green;
return result;