0
私はタイトルの長さごとにボタンのサイズを変更する必要があるアプリケーションを構築しています。私は次のコードを書いた。UIButtonのサイズ変更UIButtonのタイプを変更します
`UIButton * newButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
newButton.backgroundColor = [ UIColor clearColor];
newButton.titleLabel.backgroundColor = [ UIColor whiteColor];
[newButton setTitle:@"devsri" forState:UIControlStateNormal];
newButton.titleLabel.textColor = [ UIColor blackColor];
CGSize expectedLabelSize = [newButton.titleLabel.text sizeWithFont:newButton.titleLabel.font];
newButton.frame = CGRectMake(xBase, yBase, expectedLabelSize.width, expectedLabelSize.height);
上記のコードはテーブルのサイズを変更しますが、ボタンは表示されなくなりました。上のコードで何が間違っているかを教えてください。
ありがとうございます!