iphone - 在 TabBar 中更改选项卡时,UIButtons 文本显得更暗

标签 iphone objective-c ios uibutton

我不知道为什么会遇到这个问题。

详细信息 - 我的应用程序中有一个选项卡栏 Controller 。在一个选项卡上,我有一个包含一些按钮的表单。我正在设置这些按钮的标题。现在,当我更改标签并返回同一标签时,所有按钮标题都变暗了。

我也附上屏幕截图。

如有任何帮助,我们将不胜感激。

谢谢!!

First Second enter image description here

编辑:这是我如何创建按钮的代码 -

-(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/

相关文章:

iphone - 有没有办法在不离开 App 的情况下将评分发送到 App Store?

ios - 当您点击 iOS 主屏幕上的应用程序图标时,如何制作应用程序启动之类的动画?

iphone - 核心图问题

ios - 什么时候应该将 translatesAutoresizingMaskIntoConstraints 设置为 true?

iphone - UITextView 委托(delegate)方法

iphone - 如何动态更改 UIButton 的位置

应用程序更新时的 iPhone 数据迁移

iphone - 将 NSDictionary 插入 CoreData

ios MFMessageComposeViewController ipod 崩溃

c# - 无法使用 autoAcceptAlerts 在 iOS 上运行 Appium 测试