3
我遇到了一个UIButton的问题,我尝试以编程方式创建。问题是按钮出现了(即,如果我设置背景颜色,我可以清楚地看到按钮)并且是可点击的,但标题标签不可见。UIButton标题不显示
下面是我在做什么:
valueButton = [UIButton buttonWithType:UIButtonTypeCustom];
[valueButton addTarget:self action:@selector(openList:) forControlEvents:UIControlEventTouchUpInside];
valueButton.frame = CGRectMake(160.0, decalageLabel+6.0, 120.0, 20.0);
[valueButton.titleLabel setTextAlignment:UITextAlignmentRight];
[valueButton.titleLabel setFont:[UIFont fontWithName:@"Helvetica-Neue-Light" size:17.0]];
UIColor * colorLabelValue = [[UIColor alloc] initWithRed:131.0/255.0 green:159.0/255.0 blue:86.0/255.0 alpha:1.0] ;
[valueButton setTitleColor:colorLabelValue forState:UIControlStateNormal];
if(txtValueField == NULL){
txtValueField = @"";
}
valueButton.titleLabel.text = [NSString stringWithFormat:@"%@", txtValueField];
NSLog(@"button : %@ ", valueButton.titleLabel.text);
[self.contentView addSubview:valueButton];
哦,我已经取得了一定的标题有一个实际值,由NSLogging其文本值,它工作正常。所以我不知道发生了什么。任何想法?
就是这样!非常感谢 ;) – ChrisTauziet 2012-03-07 16:26:42