Xamarin.forms 表单:如何在iOS设备上隐藏导航栏分隔符?
我已在Xamarin.forms 表单:如何在iOS设备上隐藏导航栏分隔符?,xamarin.forms,Xamarin.forms,我已在app.xaml中使用这些代码更改了导航栏的默认颜色,因为我无法使其在iOS设备上透明: <Style TargetType="NavigationPage"> <Setter Property="BarBackgroundColor" Value="#0a82b8" /> <Setter Property="BarTextColor" Value="#ffffff" /> </Style>
app.xaml
中使用这些代码更改了导航栏的默认颜色,因为我无法使其在iOS设备上透明:
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="#0a82b8" />
<Setter Property="BarTextColor" Value="#ffffff" />
</Style>
是我在MasterDetail导航中遵循的教程。带有
标记的文件名为MainPage.xaml
您可以使用自定义渲染器隐藏该阴影:
[assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNavigationPage))]
namespace CustomNavigationPage.iOS
{
public class CustomNavigationPage : NavigationRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
NavigationBar.SetBackgroundImage(new UIKit.UIImage(), UIKit.UIBarMetrics.Default);
NavigationBar.ShadowImage = new UIKit.UIImage();
}
}
}
可以使用自定义渲染器隐藏该阴影:
[assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNavigationPage))]
namespace CustomNavigationPage.iOS
{
public class CustomNavigationPage : NavigationRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
NavigationBar.SetBackgroundImage(new UIKit.UIImage(), UIKit.UIBarMetrics.Default);
NavigationBar.ShadowImage = new UIKit.UIImage();
}
}
}
虽然您已经接受了答案,但这一条更为准确-您没有按照从网站粘贴的说明进行操作,因为您已经编辑了这一行:
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
虽然您已经接受了答案,但这一条更为准确-您没有按照从网站粘贴的说明进行操作,因为您已经编辑了这一行:
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
放置
UINavigationBar.Appearance.ShadowImage=newuiimage()在AppDelegate.cs文件中的public override bool FinishedLaunching(UIApplication-app,NSDictionary选项)
方法中的code>。AppDelegate.cs位于Xamarin的iOS项目中。表单PlaceUINavigationBar.Appearance.ShadowImage=new UIImage()在AppDelegate.cs文件中的public override bool FinishedLaunching(UIApplication-app,NSDictionary选项)
方法中的code>。AppDelegate.cs位于Xamarin的iOS项目中。表单就像一个魔咒!非常感谢你@Brunocaceirow就像一个魔咒!非常感谢你@布鲁诺卡塞罗
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"