IOS 在 DialogViewController 中添加带有图像的标签
Add Label with Image in DialogViewController in IOS
我正在 ios(Xamarin) 中创建 SlideNavigation Drawer。我在下面 link
的帮助下创建了
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
名称,它是 "Home"。现在我想添加 Image
。
我在 google 和 SO 中搜索了很多东西。但我什么也做不了。
任何帮助将不胜感激。
您可以设置 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
});
我正在 ios(Xamarin) 中创建 SlideNavigation Drawer。我在下面 link
的帮助下创建了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
名称,它是 "Home"。现在我想添加 Image
。
我在 google 和 SO 中搜索了很多东西。但我什么也做不了。
任何帮助将不胜感激。
您可以设置 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
});