Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChristina Keavaney
424 Pointscould not get the button text color to change, would stay the same default (teal) color each time i pressed the button.
import "ViewController.h"
import "FactBook.h"
import "ColorWheel.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad { [super viewDidLoad]; self.factBook = [[FactBook alloc]init]; self.colorWheel = [[ColorWheel alloc] init];
// UIColor *randomColor = [self.colorWheel randomColor]; // self.view.backgroundColor = randomColor; // self.funFactButton.tintColor = randomColor; // self.funFactLabel.text = [self.factBook randomFact];
self.randomColor = [self.colorWheel randomColor];
self.view.backgroundColor = self.randomColor;
self.funFactLabel.text = [self.factBook randomFact];
[self.funFactButton setTitleColor:self.randomColor forState:0];
}
- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
- (IBAction)showFunFact {
// UIColor *randomColor = [self.colorWheel randomColor]; // self.view.backgroundColor = randomColor; // self.funFactButton.tintColor = randomColor; // self.funFactLabel.text = [self.factBook randomFact];
self.randomColor = [self.colorWheel randomColor];
self.view.backgroundColor = self.randomColor;
self.funFactLabel.text = [self.factBook randomFact];
[self.funFactButton setTitleColor:self.randomColor forState:0];
}
@end
2 Answers
Matthew Ferris
2,981 Pointsjust moving this down as the answer from 2 months ago, it was entered as a comment instead:
Dr.P reon 2,678 2mo ago Hello there,
Did you try... self.funFactButton.tintColor = randomColor;
Daniel Mendez
6,296 PointsThis is what I did to change the title color:
[self.buttonLabel setTitleColor:self.randomColor forState:UIControlStateNormal];
View the stack overflow post for more info: http://stackoverflow.com/questions/2474289/how-can-i-change-uibutton-title-color
Dr.P reon
8,562 PointsDr.P reon
8,562 PointsHello there,
Did you try... self.funFactButton.tintColor = randomColor;