在IOS的DialogViewController中添加带有Image的Label(Add Label with Image in DialogViewController in IOS)

编程入门 行业动态 更新时间:2024-10-20 04:02:20
在IOS的DialogViewController中添加带有Image的Label(Add Label with Image in DialogViewController in IOS)

我在ios(Xamarin)中创建SlideNavigation Drawer。 我在下面链接的帮助下创建了

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

任何帮助将不胜感激。

I am creating SlideNavigation Drawer in ios(Xamarin). and I have created with help of below link

https://github.com/thedillonb/MonoTouch.SlideoutNavigation

The code is working fine as I want.

Code :

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); } }

But As you can see I have only able to add String name in my code case it is "Home". Now I want to add Image.

I search lot's of thing in google and SO. But nothing is work me.

Any Help will be Appreciated.

最满意答案

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

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 });

You can set Image property of StyledStringElement That will solve your problem.

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 });

更多推荐

本文发布于:2023-08-04 08:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1412550.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:DialogViewController   IOS   Image   Add   Label

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!