2016-03-28 13 views
0

ボタンのタイトルラベルをカスタムフォントの色とタイトルで変更したい。 ViewControllerがロードされたとき、私はインターフェイスビルダーに追加として1秒間にカスタマイズして、表示されるボタンをボタンのラベルのフォントの色とタイトルを変更する

がここにUIButtonのために私のコード

edit_button.frame = CGRectMake(120, 40, 30, 30); 
edit_button.titleLabel.text = @""; 
edit_button.titleLabel.font = [UIFont fontWithName:@"FontAwesome" size:13.0f]; 
edit_button.titleLabel.textColor = [UIColor colorWithRed:0.278 green:0.608 blue:0.565 alpha:1]; 

答えて

0

は、ボタンをこのように設定してください:

[button setTitle:@"Button title" forState:UIControlStateNormal]; 
[button setTitleColor:[UIColor colorWithRed:0.278 green:0.608 blue:0.565 alpha:1] forState:UIControlStateNormal]; 
[button.titleLabel setFont:[UIFont fontWithName:@"FontAwesome" size:13.0f]]; 
1

で表示され、タイトルラベルのプロパティが設定されています以下のような:

[edit_button setFrame:CGRectMake(x,y,width,height)]; 
    [edit_button setTitle:@"[]" forState:UIControlStateNormal]; 
    [edit_button setTitleColor:[UIColor colorWithRed:0.278 green:0.608 blue:0.565 alpha:1] forState:UIControlStateNormal]; 
    [edit_button.titleLabel setFont:[UIFont fontWithName:@"FontAwesome" size:13.0f]]; 
0

は、[edit_buttonのsetTitle:@ "[]" forState:UIControlStateNormal];あなたのviewWillAppearで:あなたのViewControllerの方法

方法 loadButtonを実装

-(void)loadButton 
{ 
    edit_button.frame = CGRectMake(120, 40, 30, 30); 
    [edit_button setTitle:@"TITLE" forState:UIControlStateNormal]; 
    edit_button.titleLabel.font = [UIFont fontWithName:@"FontAwesome" size:13.0f]; 
    [edit_button setTitleColor: [UIColor colorWithRed:71/255 green:155/255 blue:144/255 alpha:1 forState:UIControlStateNormal];//BE SURE TO DEVIDE BY 255] 
    [self.view addSubview:edit_button] 
} 
より
[self performSelector:@selector(loadButton) withObject:nil afterDelay:1.0f]; 

関連する問題