【问题标题】:How to add humburger icon in MasterDetailPage in xamarin.Forms(iOS)如何在 xamarin.Forms(iOS) 的 MasterDetailPage 中添加汉堡图标
【发布时间】:2017-06-22 09:19:58
【问题描述】:

我是 Xamarin.Forms 的新手。我正在为 iOS 和 Android 创建 NavigationPage。所有的东西都设置好了。请参阅下面的屏幕截图。

在 Android 中这是外观

但在 iOS 中显示不好

代码:

MasterPage.xaml

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="DroidDrawer.MasterPage" Padding="0,0,0,0" Title="Menu" Icon="humburger">
    <ContentPage.Content>
        <StackLayout VerticalOptions="FillAndExpand" Orientation="Vertical" Padding="0,20,0,0" BackgroundColor="#004F80">
            <ListView x:Name="listView" VerticalOptions="FillAndExpand" SeparatorVisibility="None" BackgroundColor="#0072BA">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                <Image Source="{Binding IconSource}" HeightRequest="24" WidthRequest="24" VerticalOptions="Center" Grid.Column="0" Margin="12,10,0,10" />
                                <Label Text="{Binding Title}" Style="{DynamicResource LabelStyle}" VerticalOptions="Center" HeightRequest="24" TextColor="White" Grid.Column="1" Margin="10,13,0,10" />
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

MasterPage.xaml.cs

using System;
using System.Collections.Generic;

using Xamarin.Forms;

namespace DroidDrawer
{
    public partial class MasterPage : ContentPage
    {
        public ListView ListView { get { return listView; } }
        public MasterPage()
        {
            InitializeComponent();

            var masterPageItem = new List<MasterPageItem>();
            masterPageItem.Add(new MasterPageItem
            {
                Title = "Home",
                IconSource = "nav_home.png",
                TargetType = typeof(HomePage)
            });
            masterPageItem.Add(new MasterPageItem
            {
                Title = "CSS",
                IconSource = "nav_appointment.png",
                TargetType = typeof(CssPage)
            });
            masterPageItem.Add(new MasterPageItem
            {
                Title = "Javascript",
                IconSource = "nav_feedback.png",
                TargetType = typeof(JavascriptPage)
            });
            masterPageItem.Add(new MasterPageItem
            {
                Title = "Html",
                IconSource = "nav_financialinfo.png",
                TargetType = typeof(HtmlPage)
            });

            listView.ItemsSource = masterPageItem;

        }
    }
}

我们将不胜感激。

【问题讨论】:

    标签: xamarin.ios navigation xamarin.forms navigation-drawer


    【解决方案1】:

    6 小时后,我得到了解决问题的方法,即图标尺寸太大,无法在屏幕上显示这么大。设置30*30图片大小后问题解决了...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-30
      • 2018-08-16
      • 2023-03-10
      • 1970-01-01
      相关资源
      最近更新 更多