Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 2    Views: 57

NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
03/15/15 09:09 PM (9 years ago)

getColorFromHexString ?

Trying to use "getColorFromHexString" rather than some other code, and I must be missing something with using the UIColor that it returns. Have previously saved out a hex string, and now after loading it back in on another string want to use that value for a background color... Reading in the string containing the hexstring works fine.... NSString *tmpColorString = [BT_strings getPrefString: @"my_themeColor"]; NSLog(@"viewWillAppear my_themeColor loaded = %@" ,tmpColorString ); //loads ok // test case loaded FF0000 for red as was expected However UIColor *newThemeColor = [BT_color getColorFromHexString:tmpColorString]; NSLog(@"newThemeColor = %@" , newThemeColor ); // this reports "newThemeColor = UIDeviceWhiteColorSpace 0 0" myUIViewName.backgroundColor = newThemeColor; // <- not working ========================== Any thoughts on what I missed? Thanks myUIViewName.backgroundColor = [UIColor redColor]; // debug just to verify test works
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/15/15 10:37 PM (9 years ago)
needs a # before the hex code UIColor *newThemeColor = [BT_color getColorFromHexString:[NSString stringWithFormat:@"#%@",tmpColorString]];
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
03/16/15 04:37 AM (9 years ago)
Thanks Chris! Works fine, now that it knows the format of the string- still learning;)
 

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.