Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I set my button's shadow colour?

I'm trying to set the shadow colour on a UIButton, but all I seem to be able to get is a mid grey.

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(20, 20, 200, 100);

[button setTitle:@"a" forState:UIControlStateNormal];

[button addTarget:self 
           action:@selector(buttonPressed:) 
 forControlEvents:UIControlEventTouchUpInside];

[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button.titleLabel setFont:[UIFont fontWithName:@"Helvetica" size:96]];

// set up the button colours 
button.titleLabel.shadowColor = [UIColor blueColor];
[button.titleLabel setShadowOffset:CGSizeMake(5.0f, 5.0f)];

[self.view addSubview:button];

alt text http://img.skitch.com/20090825-xur3112ni5q2wrwwiix4jbcwc5.png

Am I setting the wrong property, or is it the way that I'm setting shadowColor that's wrong?

Thanks.

like image 751
nevan king Avatar asked Aug 25 '09 07:08

nevan king


1 Answers

Have you tried:

[button setTitleShadowColor:[UIColor blueColor] forState:UIControlStateNormal];
like image 64
dreamlax Avatar answered Oct 25 '22 10:10

dreamlax