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];
结果是只有当我按住按钮时才会显示文本。默认情况下不是。
怎么了?