Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set default tint color for all UIButtons in an app

My iPad app I has a number of UIButtons that when pressed turn blue by default. I could go through each one and set the tintcolor using:

[buttonName setTintColor:[UIColor colorWithRed:151/255.0f green:202/255.0f blue:86/255.0f alpha:1.0]];

But is there anyway of changing this colour by default and for all buttons?

Is there anyway of changing this colour?

like image 698
RGriffiths Avatar asked Sep 04 '13 13:09

RGriffiths


2 Answers

If you are using storyboards and Xcode 5.0 or later, the easiest way to do this is to open up your storyboard in Xcode and set the Global Tint color setting in the File Inspector in the Utility area. See illustration below.

Setting the Global Tint in the File Inspector

like image 198
jengelsma Avatar answered Sep 21 '22 20:09

jengelsma


Use the UIAppearance Protocol:

 [[UIButton appearance] setTintColor:[UIColor colorWithRed:151/255.0f green:202/255.0f blue:86/255.0f alpha:1.0]]; 
like image 43
peko Avatar answered Sep 21 '22 20:09

peko