在iOS中的DialogViewController中添加带有图像的标签



我在iOS(Xamarin)中创建SlidEnecigation抽屉。我在以下链接

的帮助下创建了

https://github.com/thedillonb/monotouch.slideoutnavigation

代码正常工作。

代码:

class DummyControllerLeft : DialogViewController
    {
        float labelHeight;
        UIImageView profileImage;
        public DummyControllerLeft()
           : base(UITableViewStyle.Plain, new RootElement(""))
        {
            this.labelHeight = labelHeight;
            Root.Add(new Section()
            {
                new StyledStringElement("Home", () => NavigationController.PushViewController(new HomeViewController(), true)) { TextColor = UIColor.White, BackgroundColor = UIColor.Clear, Font = UIFont.FromName("Helvetica-Bold", 16f) },
            });
            TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
            TableView.BackgroundColor = UIColor.Clear.FromHexString("#0072BA", 1.0f);
        }
}

,但是如您所见,我只能在我的代码案例中添加String名称,它是"家"。现在我想添加Image

我在Google中搜索了很多东西。但是我什么都没有。

任何帮助将不胜感激。

您可以设置StyledStringElement的图像属性这将解决您的问题。

StyledStringElement home = new StyledStringElement ("Home", () => NavigationController.PushViewController (new HomeViewController (), true)) { TextColor = UIColor.White, BackgroundColor = UIColor.Clear };
home.Image = new UIImage ("noimage.png");
Root.Add (new Section () {
                        home
                    });

最新更新