0
我試圖添加UIImageView以及文本UISegmentedControl
。請注意,我不想將圖像設置爲背景,並且我已經在IB中獲得了分段控制。我到目前爲止所嘗試的是:如何將圖像添加到UISegmentedControl文本的一側
for (id segment in [segmentControl subviews])
{
for (id label in [segment subviews])
{
if ([label isKindOfClass:[UILabel class]])
{
float width = ((UILabel*)label).bounds.size.width;
UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Arrow-down.png"]];
image.frame = CGRectMake(width + 2, 15 , 32, 32);
((UILabel*)label).frame = CGRectMake(((UILabel*)label).frame.origin.x,((UILabel*)label).frame.origin.y, width + image.frame.size.width + 5, ((UILabel*)label).frame.size.height);
[(UILabel*)label insertSubview:image atIndex:0];
}
}
}
請有人指導我嗎?謝謝。的UILabel的
感謝快速回復。我在我的問題中提到我不想將圖像設置爲背景。我想在UILabel文本結束的圖像。 – NightFury