2

ボタンはもう作りました。クリックすると大きくなりますが、文字の位置が悪いです。大きなボタンの中に別のボタンを入れたい。これどうやってするの ?

4

1 に答える 1

0

最初のボタンのサブビューとして 2 番目のボタンを追加するだけの場合は、次のように使用できます。

UIButton *mySmallButton = [[UIButton alloc] initWithFrame:CGRectMake:(0, 0, 50, 50)];
[mySmallButton setBackgroundColor:[UIColor redColor]];
[myBigButton addSubview:mySmallButton];

ただし、最初のボタンが大きくなったときにテキストのサイズ/配置を変更するだけの場合は、次を使用できます。

[[myBigButton titleLabel] setTextAlignment:UITextAlignmentCenter];
[[myBigButton titleLabel] setFont:[UIFont systemFontOfSize:24]];
于 2012-09-05T16:10:11.570 に答える