c# - Setting custom font on all UIButtons -


i want apply custom font buttons in ios app i've created in xamarin. i've achieved custom font on labels previous code:

//labels uilabel.appearance.font = uifont.fromname("lato-light",16f); 

...which affects not buttons reason. tried targeting label on button so:

var buttonappearance = uilabel.appearancewhencontainedin(typeof (uibutton)); buttonappearance.font = uifont.fromname("lato-light", 16f); 

...which nothing. should targeting button title instead? know there lots of questions on here concerning how set in xcode i'm working c# in xamarin.ios. thanks!

so since there no uibutton.appearance.font, can use c# workaround use.

make extension method (inside static class):

public static void applytheme(this uibutton button) {     //set font on button or whatever } 

then call code on every uibutton in app:

//in viewdidload, awakefromnib, etc. mybutton.applytheme(); 

this give styling buttons can modify app changes.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -