0
私はダイナミックなサイズでのUIViewを必要とする(それが1つのまたは2のラベルをcontaingことができます)と私はこのような何か:私はOKそのUIViewにサブビューを追加した後、UIViewのフレームを設定できますか?
float nextY = 0.0f;
float labelHeight = 20.0f;
UIView *tempView = [[UIView alloc] initWithFrame:CGRectZero];
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, nextY, 100.0f, labelHeight)];
label1.text = @"Test 1";
[tempView addSubview:label1];
nextY += labelHeight;
if (something == YES)
{
UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, nextY, 100.0f, labelHeight)];
label1.text = @"Test 2";
[tempView addSubview:label2];
nextY += labelHeight;
}
tempView.frame = CGRectMake(0.0f, 0.0f, 100.0.f, nextY);
を?
実際にログインしてこの質問をするよりも実際に実行をクリックする方が早いでしょうか? –
まあ、はい私はそれが動作することを知っているが、私はちょうどこれを行う_correct_方法であるかどうかを知りたい... –