Custom font settings for Monotouch dialog elements

Is there a way to install fonts when the Monotouch Dialog class was launched?

[Section("This is the header")] 

It will be displayed with blue text by default with shadow entry, but I can not find where this font is installed. Is there a way to rewrite the font and color that it uses?

+4
source share
2 answers

I have found a solution for those who want to replace all section headings in the whole solution. In MonoTouch.Dialog there is a class called DialogViewController that is used when creating views with the reflection API. And here is a method called GetViewForHeader() . Instead of sending just the regular section.HeaderView you can create a custom shortcut and send it back.

 public override UIView GetViewForHeader (UITableView tableView, int sectionIdx) { var section = Root.Sections [sectionIdx]; if (!string.IsNullOrEmpty(section.Caption)) { var label = new UILabel(); label.BackgroundColor = UIColor.FromRGB(89, 41, 17); label.TextColor = UIColor.FromRGB(255, 206, 52); label.ShadowColor = UIColor.Black; label.ShadowOffset = new SizeF(0, 1f); label.Font = UIFont.FromName("TitlingGothicFB Cond", 20); label.Text = section.Caption; return label; } return section.HeaderView; } public override float GetHeightForHeader (UITableView tableView, int sectionIdx) { if (!string.IsNullOrEmpty(section.Caption)) return 40f; return -1; } 

Remember to set the height, either manually or by getting the height from the mark. You can also create a custom UIView , but a shortcut is enough for me.

+6
source

When you use such a section, you will use standard UITableView rendering.

The only way to change this is to use the Element API instead of the reflection API and provide a UIView where you draw the contents of the data yourself.

0
source

Source: https://habr.com/ru/post/1338627/


All Articles