문제

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)];

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top