0
UIImage *segmentSelected = [[UIImage imageNamed:@"Button_on"] resizableImageWithCapInsets2:UIEdgeInsetsMake(7, 7, 7, 7)];
UIImage *segmentUnselected = [[UIImage imageNamed:@"Button_off"] resizableImageWithCapInsets2:UIEdgeInsetsMake(7, 7,7,7)];

for (UIButton * button in @[self.catalog,self.business]) {
    [button setBackgroundImage:segmentSelected forState:UIControlStateSelected];
    [button setBackgroundImage:segmentUnselected forState:UIControlStateNormal];
}
self.business.selected=true;
[self.business setTitle:@"Business" forState:UIControlStateNormal];
[self.catalog setTitle:@"Catalog" forState:UIControlStateNormal];

结果是只有当我按住按钮时才会显示文本。默认情况下不是。

怎么了?

4

2 回答 2

2

为所有状态设置标题:

[self.business setTitle:@"Business" forState:UIControlStateNormal];
[self.catalog setTitle:@"Catalog" forState:UIControlStateNormal];
[self.business setTitle:@"Business" forState: UIControlStateHighlighted];
[self.catalog setTitle:@"Catalog" forState: UIControlStateHighlighted];
[self.business setTitle:@"Business" forState: UIControlStateSelected];
[self.catalog setTitle:@"Catalog" forState: UIControlStateSelected];

工作?

于 2013-01-22T12:46:20.380 回答
0

这必须是一个错误。

将文本颜色更改为另一种颜色可以解决问题。但我想要白色。所以我所做的是颜色中有 2 个白框。

“默认”白色和“白色”白色。

将东西更改为白色白色,瞧,它起作用了。

于 2013-01-23T03:06:56.343 回答