UIButton
我在我的viewDidLoad
方法中加载了一些默认值并设置了自定义项。默认加载正常。但是,UIButtons
他们没有得到他们的定制。
当我将完全相同的UIButton
代码放在操作按钮中以触发自定义时 - 效果很好。我在 .xib 中将按钮更改为“自定义”。
我觉得发生了一些不正常的事情,这就是为什么按钮没有随他们的模组一起启动的原因。
- (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];
}