我不知道为什么会遇到这个问题。
详细信息 - 我的应用程序中有一个选项卡栏 Controller 。在一个选项卡上,我有一个包含一些按钮的表单。我正在设置这些按钮的标题。现在,当我更改标签并返回同一标签时,所有按钮标题都变暗了。
我也附上屏幕截图。
如有任何帮助,我们将不胜感激。
谢谢!!
编辑:这是我如何创建按钮的代码 -
-(void)viewWillAppear:(BOOL)animated
{
float yFrame =310.0f;
for(int i =0;i<7;i++){
openPickerButton=[UIButton buttonWithType:UIButtonTypeCustom];
openPickerButton.frame = CGRectMake(29.0, yFrame+10.0, 280.0, 48.0);
openPickerButton.tag=i;
openPickerButton.backgroundColor=[UIColor clearColor];
[openPickerButton setTitle:[formButtonTitle objectAtIndex:openPickerButton.tag] forState:UIControlStateNormal];
openPickerButton.titleLabel.font=[UIFont fontWithName:@"Helvetica" size:16];
[openPickerButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
openPickerButton.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
openPickerButton.showsTouchWhenHighlighted = YES;
[openPickerButton addTarget:self action:@selector(PickChoreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[setPreferencesFormScrollView addSubview:openPickerButton];
yFrame+=60.0f;
}
}
最佳答案
好吧,在 viewDidLoad 中,你的对象被调用一次。(一旦 View 被加载。 停止) 在 viewWillAppear 中,每次出现 View 时都会调用它们。
- (void)viewDidLoad
{
[super viewDidLoad];
float yFrame =310.0f;
for(int i =0;i<7;i++){
openPickerButton=[UIButton buttonWithType:UIButtonTypeCustom];
openPickerButton.frame = CGRectMake(29.0, yFrame+10.0, 280.0, 48.0);
openPickerButton.tag=i;
openPickerButton.backgroundColor=[UIColor clearColor];
[openPickerButton setTitle:[formButtonTitle objectAtIndex:openPickerButton.tag] forState:UIControlStateNormal];
openPickerButton.titleLabel.font=[UIFont fontWithName:@"Helvetica" size:16];
[openPickerButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
openPickerButton.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
openPickerButton.showsTouchWhenHighlighted = YES;
[openPickerButton addTarget:self action:@selector(PickChoreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[setPreferencesFormScrollView addSubview:openPickerButton];
yFrame+=60.0f;
}
}
关于iphone - 在 TabBar 中更改选项卡时,UIButtons 文本显得更暗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10856024/