ラベル間に自動スペースを設定するにはどうすればよいですか。動的テキストがラベルに提供され、2番目のラベルは、両方が上書きされないように、それ自体を自動フレーム化する必要があります。どうすればこれを達成できますか。最初のラベルのテキストが終了し、次に2番目のラベルが前のラベルからの距離を保ち始めるときに必要です。上記のご案内をお願いします。前もって感謝します。
2 に答える
1
これを試して
CGSize size = [firstLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]];
secondLabel.frame=CGRectMake(size.width+20,4, 9, 14);
詳細については、これをチェックしてください。異なる長さの文字列に従ってUIlableの長さを取得します
画像サイズを取得するため
UIImage *tempimage= [UIImage imageWithContentsOfFile:fullImgNm];
Float width = tempimage.size.width;
したがって、imageviewフレームは
yourImageView.frame=CGRectMake(size.width+20,4,width, 14);
2番目のラベルフレームは
secondLabel.frame=CGRectMake(size.width+width+20,4, 9, 14);
于 2013-02-25T07:08:44.557 に答える
0
UILabel
プロパティを使用してフレームを調整しconstrainedToSize
ます。
CGRect infoRect = self.conditionLabel.frame;
NSString *fileName = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"txt"];
NSString *textString = [[NSString alloc] initWithContentsOfFile:fileName encoding:NSUTF8StringEncoding error:nil];
[self.conditionLabel setText:textString];
[textString release];
CGSize defaultSize = CGSizeMake(sectionWidth, 9999.0);
UIFont *defaultFont = kCCOpenSansFont(font, 14.0);
CGSize infoSize = [[self.conditionLabel text] sizeWithFont:defaultFont constrainedToSize:defaultSize lineBreakMode:UILineBreakModeWordWrap];
infoRect.size.height = infoSize.height;
[self.conditionLabel setFrame:infoRect];
于 2013-02-25T07:08:26.113 に答える