【问题标题】:Can I make a UIMenu in Xamarin.iOS?我可以在 Xamarin.iOS 中制作 UIMenu 吗?
【发布时间】:2023-03-31 06:13:01
【问题描述】:

我在 Xamarin.iOS 中开发。我想创建一个下拉菜单,我在Apple Human Interface Guidelines 中看到了它。 但我看不到official Microsoft documentation

是否在 Xamarin.iOS 中实现?如果是,我该如何使用它?

【问题讨论】:

    标签: ios xamarin xamarin.ios mobile-development uimenu


    【解决方案1】:

    您可以检查以下代码

            UIButton button = new UIButton()
            {
                Frame = new CoreGraphics.CGRect(30,100,200,80),
                Menu = CreateMenu(),
    
    
            };
    
            button.SetTitle("Click Test", UIControlState.Normal);
            button.SetTitleColor(UIColor.SystemRedColor, UIControlState.Normal);
            button.ShowsMenuAsPrimaryAction = true;
            View.AddSubview(button);
    
           UIMenu CreateMenu()
            {
                
                //you can set the icon as the second parameter
                var Action1 = UIAction.Create("Action1",null,null,(arg)=> { 
                
                    // do something when you click this item
    
                });
    
                var Action2 = UIAction.Create("Action2", null, null, (arg) => {
    
                    // do something when you click this item
    
                });
    
                var Action3 = UIAction.Create("Action3", null, null, (arg) => {
    
                    // do something when you click this item
    
                });
    
                var Menus = UIMenu.Create(new UIMenuElement[] {Action1,Action2,Action3 });
                return Menus;
            }
    

    【讨论】:

      猜你喜欢
      • 2021-10-05
      • 1970-01-01
      • 2020-12-26
      • 2016-05-24
      • 1970-01-01
      • 2015-04-14
      • 2013-10-10
      相关资源
      最近更新 更多