[英]UIButton Title Doesn't Appear unless Clicked
除了问题的标题外,我不知道如何描述问题:我有一个带有标题的按钮,该按钮在单击时会出现,但不是处于正常状态。 我无处不在环顾四周。
如果您需要查看特定的代码或需要其他详细信息(我相信您会),请告诉我。
编辑:按钮是在笔尖中创建的,但是这里是设置标题并处理按钮子视图的代码。
[chapterButton setTitle:[NSString stringWithFormat:@"%@: %d",newBookName,newChapter] forState:UIControlStateNormal];
UIImageView *triunghiView = (UIImageView *) [chapterButton viewWithTag:kTagTriangleView];
if(!triunghiView)
{
triunghiView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"triunghi.png"]] autorelease];
[triunghiView setContentMode:UIViewContentModeCenter];
[triunghiView setTag:kTagTriangleView];
[triunghiView sizeToFit];
[chapterButton addSubview:triunghiView];
}
[triunghiView setCenter:CGPointMake(chapterButton.titleLabel.frame.origin.x + chapterButton.titleLabel.frame.size.width + triunghiView.frame.size.width + 5, chapterButton.frame.size.height/2)];
我最近遇到了这个问题,您还必须设置按钮的标题颜色 ,否则它将变成白色并显示为不可见(在圆形rect按钮的默认设置中)。
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
但是,这很可能是Kjuly的答案! 没有代码很难说。
没有代码,好吧,猜想您可能为标题设置了错误的状态。
[yourButton setTitle:@"Title" forState:UIControlStateNormal];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.