【发布时间】:2015-07-13 22:07:59
【问题描述】:
我有一个分段控件,其中有 4 个分段。其中三个有标签,一个有图像。 当我使用 titleForSegmentAtIndex 时,它返回前三个的精细文本,但对于图像段,它返回 null。 任何想法为什么?
NSArray *segmentArray = [[NSArray alloc] initWithObjects: @"One", @"Two", @"Three",[UIImage imageNamed:IMAGE_ANY_NUMBER], nil];
self.timeSegments = [[UISegmentedControl alloc] initWithItems:segmentArray];
self.timeSegments.tintColor = [UIColor colorWithRed: 0x77/255.0 green:0x77/255.0 blue:0x77/255.0 alpha:1.0];
self.timeSegments.backgroundColor = [UIColor colorWithRed: 0xFB/255.0 green:0xFB/255.0 blue:0xFB/255.0 alpha:1.0];
[self addSubview:self.segmentArray];
【问题讨论】:
-
我认为您需要为第 4 段设置标题和图像。并设置标题颜色清晰,因此您只能看到与预期结果相同的图像。并且您还将获得第 4 段的标题。
标签: ios ipad uisegmentedcontrol