This is for a Toolbar item.
The following code works fine in the iOS 6 simulator and on iOS 6 devices.
The shadow offset (UITextAttributeTextShadowOffset) is ignored in iOS 5 simulator and iOS 5 devices.
[_doneButton setBackgroundImage:[UIImage imageNamed:@"standardButtonImage.png"]
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
NSDictionary *textDic = [NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Helvetica-Bold" size:15.0], UITextAttributeFont,
[UIColor whiteColor], UITextAttributeTextColor,
[UIColor blackColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(1.0,1.0)], UITextAttributeTextShadowOffset, //won't honor the offset in ios5
// it's not the font, font size, text color, background image, or order in the dictionary. Must be an Apple bug.
// also doesn't work if you specify [UIBarButtonItem appearance]
nil];
[_doneButton setTitleTextAttributes:textDic forState:UIControlStateNormal];
Has anyone had the same experience, or can anyone see anything wrong with this code?
Try this: UITextAttributeTextShadowOffset: [NSValue valueWithCGSize:CGSizeMake(1.0,1.0)];