のテキストと一緒にUIImageViewを追加しようとしていますUISegmentedControl
。画像を背景として設定したくないので、すでにIBでセグメント化されたコントロールを取得していることに注意してください。私がこれまでに試したことは次のとおりです。
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];
}
}
}
誰かが私を案内してもらえますか?ありがとう。