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 trial

iOS Build a Playlist Browser with Objective-C Working With Multiple View Controllers UIButton Recap

im stuck please help me

code is confusing me

ViewController.h
#import "UIViewController.h"
#import "UIButton.h"

@interface ViewController : UIViewController

@property (strong, nonatomic) IBOutlet UIButton *timerButton;

@end
ViewController.m
#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    UIColor *redColor = [UIColor redColor];

    // Enter your code below!

[self.timerButton setTitle:@"Start!" forState:UIControlStateNormal];
}
self.timerButton setTintColor:[UIColor redColor];

@end

1 Answer

Martin Wildfeuer
PLUS
Martin Wildfeuer
Courses Plus Student 11,071 Points

I guess your question is:

How to set the text color of a UIButton?

If so, you need to have a look at the following method

- (void)setTitleColor:(UIColor * _Nullable)color forState:(UIControlState)state

Why does tintColor not work?

From the Apple docs on UIButton's property tintColor:

This property has no default effect for buttons with type UIButtonTypeCustom. For custom buttons, you must implement any behavior related to tintColor yourself.

As a newly created UIButton defaults to the UIButtonTypeCustom type, tintColor has no effect.

P.S.

You are setting self.timerButton setTintColor:[UIColor redColor]; outside the viewDidLoad method, but I guess that's just a copy/paste error here...?