Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift UIView隐藏导航栏后退按钮文本如何使其可见?_Swift_Ios7_Xamarin.forms - Fatal编程技术网

Swift UIView隐藏导航栏后退按钮文本如何使其可见?

Swift UIView隐藏导航栏后退按钮文本如何使其可见?,swift,ios7,xamarin.forms,Swift,Ios7,Xamarin.forms,我正在尝试将导航栏背景更改为渐变红色。 我已经在导航栏中添加了子视图,它将背景设置为我想要的颜色。 但是导航栏返回按钮文本是不可见的。 后退按钮可见,但文本不可见 UIView view = new UIView(); var gradient = new CAGradientLayer(); gradient.Frame = NavigationBar.Bounds; gradient.NeedsDisplayOnBoundsChange = true; gradient.MasksToBou

我正在尝试将导航栏背景更改为渐变红色。 我已经在导航栏中添加了子视图,它将背景设置为我想要的颜色。 但是导航栏返回按钮文本是不可见的。 后退按钮可见,但文本不可见

UIView view = new UIView();
var gradient = new CAGradientLayer();
gradient.Frame = NavigationBar.Bounds;
gradient.NeedsDisplayOnBoundsChange = true;
gradient.MasksToBounds = true;
gradient.Colors = new CGColor[] { UIColor.FromRGB(248, 0, 0).CGColor, UIColor.FromRGB(143, 0, 0).CGColor };
view.Layer.InsertSublayer(gradient, 0);
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes() { TextColor = UIColor.Clear });

var bounds = NavigationBar.Bounds;
this.NavigationBar.AddSubview(view);

我用渐变色创建了图像,并将该图像用作导航栏的背景。有关iOS,请参见下面的教程

           UIGraphics.BeginImageContext(gradient.Bounds.Size);
           gradient.RenderInContext(UIGraphics.GetCurrentContext());
           UIImage backImage = Graphics.GetImageFromCurrentImageContext();
           UIGraphics.EndImageContext();      
           NavigationBar.BarStyle = UIBarStyle.Default;
           UINavigationBar.Appearance.SetBackgroundImage(backImage, UIBarMetrics.Default);