iphone - UIActivityViewController 有错误的按钮标题颜色

标签 iphone ios objective-c

我在呈现 UIActivityViewController 时遇到了一个奇怪的问题。

当我从应用程序的 Root View 中显示 UIActivityViewController 时,按钮标题的颜色是正确的。

现在,但是如果我从详细 View Controller 导航回 Root View Controller 并显示上面列出的 UIActivityViewController,则显示的 Controller 会由于某种原因继承显示 Controller 的按钮标题颜色。我试过将条形样式强制设置为默认值,但这也不起作用。设置 UIActivityViewController 的按钮外观与设置 MFMailComposeViewController 不同。

非常感谢提供的任何帮助!截图:

enter image description here enter image description here

我用来设置 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/

相关文章:

objective-c - 获取核心数据实体中的记录数

iphone - 关闭设备音量 - iOS

ios - 如何通过在不同的 View Controller 上按下按钮来更改 TableView 数据?

ios - iOS使用RxSwift跟踪异步网络调用何时完成

objective-c - iPhone/iPad : Unable to copy folder from NSBundle to NSDocumentDirectory

objective-c - NSWIndowController 创建 Nib 加载的 Outlets 序列

ios - 非常基本的自动布局

iPhone - 忽略某个区域的第二次触摸

ios - 使用 iOS 模拟器运行第一个 React Native 应用程序时未找到 index.io.bundle

objective-c - 在 UIScrollView 中滚动 UITableView