我在呈现 UIActivityViewController 时遇到了一个奇怪的问题。
当我从应用程序的 Root View 中显示 UIActivityViewController 时,按钮标题的颜色是正确的。
现在,但是如果我从详细 View Controller 导航回 Root View Controller 并显示上面列出的 UIActivityViewController,则显示的 Controller 会由于某种原因继承显示 Controller 的按钮标题颜色。我试过将条形样式强制设置为默认值,但这也不起作用。设置 UIActivityViewController 的按钮外观与设置 MFMailComposeViewController 不同。
非常感谢提供的任何帮助!截图:
我用来设置 detailviewcontroller 按钮颜色的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.topItem.title = @"Back";
UIButton *Button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[Button2 addTarget:self action:@selector(heh) forControlEvents:UIControlEventTouchUpInside];
[Button2 setImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal];
[Button2 setImage:[UIImage imageNamed:@"buttonPressed.png"] forState:UIControlStateHighlighted];
Button2.frame = CGRectMake(0.0, 0.0, 44, 44);
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:Button2];
}
最佳答案
我解决了这个问题,我不得不在关闭 UIActivityViewController 后手动更改详细 View Controller 的条形按钮项目标题颜色。
[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], [UIViewController class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, CGSizeMake(0, 0), UITextAttributeTextShadowOffset, [UIFont fontWithName:@"HelveticaNeue-Light" size:16], UITextAttributeFont, nil]
forState:UIControlStateNormal];
关于iphone - UIActivityViewController 有错误的按钮标题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17349795/