简体   繁体   English

如何使用 ZEA89B68C34CE4A63CE3077E17413 在 Xamarin Forms iOS 上设置大标题

[英]How to set large titles on Xamarin Forms iOS using Shell

Since Shell doesn't have a Navigationbar, how I can I set large Titles as described here Xamarin Forms iOS Large Title microsoft docs ? Since Shell doesn't have a Navigationbar, how I can I set large Titles as described here Xamarin Forms iOS Large Title microsoft docs ?

If I set:如果我设置:

xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core" ios:Page.LargeTitleDisplay="Always" Title="Settings"

on the ContentPage of an AppShell app nothing changes...AppShell应用程序的ContentPage上没有任何变化......

This could be achieved by using Shell Custom Renderers , and then set the Font of the TitleTextAttributes like Font = UIFont.FromName("Courier", 35f) .这可以通过使用Shell 自定义渲染器来实现,然后设置TitleTextAttributes字体,如Font = UIFont.FromName("Courier", 35f)

Here's the code sample below for your reference:下面是代码示例供您参考:

using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(APPNAME.AppShell), typeof(APPNAME.iOS.Renderers.CustomShellRenderer))]
namespace APPNAME.iOS.Renderers
{

    public class CustomShellRenderer : ShellRenderer
    {
        protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection shellSection)
        {
            var renderer = base.CreateShellSectionRenderer(shellSection);
            
            if (renderer != null)
            {
                if (renderer is ShellSectionRenderer shellRenderer)
                {
                    
    
                    var appearance = new UINavigationBarAppearance();
                    appearance.ConfigureWithOpaqueBackground();
                    appearance.BackgroundColor = new UIColor(red: 0.86f, green: 0.24f, blue: 0.00f, alpha: 1.00f);
                    
                    appearance.TitleTextAttributes = new UIStringAttributes() { 
                    ForegroundColor = UIColor.White,  
                    Font = UIFont.FromName("Courier", 35f)
};
                    
              
                    shellRenderer.NavigationBar.Translucent = false;
                    shellRenderer.NavigationBar.StandardAppearance = appearance;
                    shellRenderer.NavigationBar.ScrollEdgeAppearance = shellRenderer.NavigationBar.StandardAppearance;
                    
                }
            }

            return renderer;
        }
        
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Xamarin Forms Shell 在 iOS 中的 Tabbar 行和图标之间添加空格? - How to add a space between the Tabbar line and the icons in iOS using Xamarin Forms Shell? 如何使用 Xamarin 表单在 iOS 中设置 GPS 位置确认弹出窗口的间隔时间 - How to set Interval time for the GPS location Confirmation popup in iOS using Xamarin forms 如何在iOS的xamarin Forms Frame中设置虚线边框颜色? - How to set Dashed border color in xamarin forms Frame in iOS? iOS上的Xamarin表单如何设置页面的屏幕方向? - Xamarin Forms on iOS How To Set Screen Orientation for Page? 如何在适用于 IOS 的 xamarin.forms 应用程序中设置应用程序的应用程序图标 - how to set app icon of app in xamarin.forms app for IOS 如何在 iOS 中为 navigationBar 和 tabBarItem 设置不同的标题? - How to set different titles for navigationBar and tabBarItem in iOS? 如何使用Xamarin表单ios PickerRenderer更改Picker字体大小? - How to change Picker font size using Xamarin forms ios PickerRenderer? 如何使用 Xamarin.Forms.Maps 在 iOS 上使用 Google 地图? - How to use Google Maps on iOS using Xamarin.Forms.Maps? 设置高度条目渲染的Xamarin形式的iOS - set Height Entry rendered xamarin forms ios 如何使用 Xamarin forms 获取 iOS 的设备序列号 - How to get device serial number of an iOS using Xamarin forms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM