gpt4 book ai didi

c# - Xamarin.Forms Shell 页面中的自定义 TitleView(顶部栏)

转载 作者:行者123 更新时间:2023-12-04 23:59:24 26 4
gpt4 key购买 nike

我正在尝试创建自定义 TitleView(Shell 页面的顶部栏,汉堡包图标菜单所在的位置)。现在,在设计中,我在该区域有一些元素 - 通知铃、信息按钮和带名称的用户图像。但是,作为 xamarin.forms 的 Xamarin.Forms 不允许轻松覆盖此元素。

我将如何为它创建自定义 Controller ?我可以为条目、标签、文本编辑器等执行此操作,但我尝试过的任何东西都不适用于 TitleView。

下面是当前状态的图像(我什至不能改变汉堡包图标的颜色,每个 png 都变白了哈哈)

Current state

以及我希望实现的目标:

Desired outcome

对于如何创建此自定义渲染器的任何指示和解释,我将不胜感激。谢谢大家!

最佳答案

请参阅有关如何在 Shell 应用程序中自定义 TitleView 的官方文档:

Xamarin.Forms Shell pages - Documentation

章节

1 - 设置页面颜色

  • ForegroundColor,属于 Color 类型,用于定义为文本和图标添加阴影的颜色。

2 - 在导航栏中显示 View

The Shell.TitleView attached property, of type View, enables any Viewto be displayed in the navigation bar.

While this property can be set on a subclassed Shell object, it canalso be set on any pages that want to display a view in the navigationbar. For example, the following XAML shows displaying an Image in thenavigation bar of a ContentPage:

您可以在 TitleView 中添加 ImageButtons 并使用 XamarinCommunityToolkit 中的 IconTintColorEffect 来更改图标的颜色:

https://github.com/xamarin/XamarinCommunityToolkit/blob/main/samples/XCT.Sample/Pages/Effects/IconTintColorEffectPage.xaml

关于c# - Xamarin.Forms Shell 页面中的自定义 TitleView(顶部栏),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66662047/

26 4 0