UIButtonに以下のようにテキストを設定してもなぜか表示されない。
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.titleLabel.text = @"ButtonTitle";どうやらテキストの設定は、
- (void)setTitle:(NSString *)title forState:(UIControlState)stateを使わないといけないようだ。
従って最終的には以下のプログラムで落ち着く
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setTitle:@"ButtonTitle" forState:UIControlStateNormal];これからボタンにテキストを設定するときは気をつけないとな。
0 コメント:
コメントを投稿