2016-12-26 59 views
0

我在ios(Xamarin)中创建SlideNavigation Drawer。我有以下链接在IOS中使用DialogViewController中的图像添加标签

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和SO搜索很多东西。但没有什么是我的工作。

任何帮助将被赞赏。

回答

1

您可以设置图像属性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 
        }); 
+0

工作就像一个魅力。 – Ironman