「Objective-C」UIButtonクラスでボタン名称と色を設定する方法

関数説明
-(void)setTitle:(NSSTring *)title forState:(UIControlState)state
ボタンのタイトルをセットします。

-(void)setTitleColor:(UIColor *)color forState:(UIControlState)state
ボタンのタイトル色をセットします。

使用例
UIButton *uiBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
uiBtn.frame = CGRectMake(10, 10, 100, 28);
//ボタン名称の設定
[uiBtn setTitle:@"登録" forState:UIControlStateNormal];
[uiBtn setTitle:@"更新" forState:UIControlStateHighlighted];
//ボタン名称の色設定
[uiBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[uiBtn setTitleColor:[UIColor grayColor] forState:UIControlStateDisabled];

Objective-C

Posted by arkgame