I load some defaults and set UIButton
customizations in my viewDidLoad
method. The defaults load fine. However, the UIButtons
do not get their customization.
When I put the exact same UIButton
code in an action button to trigger the customizations - it works great. I changed the button to "Custom" in the .xib.
I feel like something is happening out of order and that is why the buttons do not launch with their mods.
- (void)viewDidLoad {
lifeTotal.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"bankKey"];
floatTot = [[NSUserDefaults standardUserDefaults] floatForKey:@"floatKey"];
dollaInt = [[NSUserDefaults standardUserDefaults] integerForKey:@"intKey"];
hourlyRate.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"rateKey"];
rate = [[NSUserDefaults standardUserDefaults] integerForKey:@"rateInt"];
NSArray *buttons = [NSArray arrayWithObjects: self.start, self.stop, self.fbButton, self.clearLifeTotal,nil];
for(UIButton *btn in buttons)
{
// Set the button Text Color
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
// Set default backgrond color
[btn setBackgroundColor:[UIColor blackColor]];
// Round button corners
CALayer *btnLayer = [btn layer];
[btnLayer setMasksToBounds:YES];
[btnLayer setCornerRadius:5.0f];
// Apply a 1 pixel, black border around Buy Button
[btnLayer setBorderWidth:1.0f];
[btnLayer setBorderColor:[[UIColor blackColor] CGColor]];
}
[super viewDidLoad];
}