工具栏项目不尊重iOS 5中的UITextAttributeTextShadowOffset

问题描述:

这是针对工具栏项目的。工具栏项目不尊重iOS 5中的UITextAttributeTextShadowOffset

以下代码在iOS 6模拟器和iOS 6设备上正常工作。

在iOS 5模拟器和iOS 5设备中忽略阴影偏移量(UITextAttributeTextShadowOffset)。

[_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]; 

有没有人有过相同的经历,或任何人都可以看到这个代码有什么问题?

试试这个:UITextAttributeTextShadowOffset:[NSValue valueWithCGSize:CGSizeMake(1.0,1.0)];

+0

优秀的答案。这完全解决了我的问题。 – groomsy