到目前为止,我已经更新了应用程序的导航栏后退按钮项目,以便在iOS 7中查看,因为它在iOS 6中显示,但我无法在iOS 7中显示文本阴影。
iOS 7:
iOS 6:
(测试时偏移量变大)
代码:
UIButton *backButton = [[UIButton alloc] initWithFrame: CGRectMake(0, 0, 80.0f + width_offset, 30.0f)];
UIImage *buttonImage = [[UIImage imageNamed:@"navigation_back_btn"] resizableImageWithCapInsets:UIEdgeInsetsMake(5, 15, 5, 5)];
[backButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
[backButton setTitle:title forState:UIControlStateNormal];
[backButton.titleLabel setFont:[UIFont defaultFontWithType:kFontBold andSize:12]];
[backButton.titleLabel setTextColor:[UIColor whiteColor]];
[backButton.titleLabel setShadowColor = [UIColor blackColor]];
[backButton.titleLabel setShadowOffset:CGSizeMake(5.0f, 5.0f)];
[backButton addTarget:viewController action:@selector(popBack) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
viewController.navigationItem.leftBarButtonItem = backButtonItem;
我还想将按钮向左移动,但这并不重要。
答案 0 :(得分:4)
尝试在UIButton
本身上设置标题阴影颜色:
[backButton setTitleShadowColor:[UIColor blackColor] forState:UIControlStateNormal];