Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 4    Views: 1434

Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
01/22/13 12:04 AM (13 years ago)

(iOS tip) Converting a Hex color code to a UIColor code

Do you only have the hex code for a beautiful color? Yet you want to use that same color in an iOS project or in a BuzzTouch plugin? Then you will need to convert that hex value to a UIColor! The UIColor web site makes it easy to do that conversion. It gives you the Obj-C code for that specific color. http://uiColor.org For example, I needed the UIColor for hex code #EEEEEE. I typed in EEEEEE into the bottom box on the right side of the UIColor.org web page. In response, the web site showed this Obj-C code: UIColor * color = [UIColor colorWithRed:238/255.0f green:238/255.0f blue:238/255.0f alpha:1.0f]; I copied most of that Obj-C code into the Menu-with-Header-Plus plugin (I am modifying Susan's plugin to show a small image and small text box in place of the Header Image). For the modified plugin, that then gives the 'rightBox' a light gray background color: [rightBox setBackgroundColor: [ UIColor colorWithRed:238/255.0f green:238/255.0f blue:238/255.0f alpha:1.0f ] ]; Have fun! -- Niraj
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/22/13 12:29 AM (13 years ago)
Very Nice! Thanks! Cheers! -- Smug
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
01/22/13 01:16 AM (13 years ago)
Here is the Buzztouch way, I would make use of this if you are designing plugins and want it to be linked properly. The example below changes a buttons color add #import BT_color [self.button setColor:[BT_color getColorFromHexString:[BT_strings getJsonPropertyValue:screenData.jsonVars:@"controlPanelButtonJsonValue":@"#000000"]] Here is your example BT style. [rightBox setBackgroundColor:[BT_color getColorFromHexString:[#EEEEEE]]; It is amazing waht sort of methods David has included into our Buzztouch source code The code should be correct or the gist should be not by my mac
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
01/22/13 01:24 AM (13 years ago)
Sweet mama, thanks Andy! The BT API needs to be documented and I should be perusing the BT code! I assume if I do it "the BT way", then there is a similar BT API method on the Android side?
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
01/22/13 01:27 AM (13 years ago)
Yup, it will be something very similar, that is how you change the button colors and backgrounds in the control panel. I've explored loads of the buzztouch code, to become a true Buzztouch Warrior you must become one with the source code lol
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.