工具栏项目不支持iOS 5中的UITextAttributeTextShadowOffset

Ray*_*eck 3 uitoolbaritem ios5 ios6

这是一个工具栏项目.

以下代码在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];
Run Code Online (Sandbox Code Playgroud)

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

小智 10

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