为什么在通过消息共享内容时,文本撰写中缺少取消按钮?

Why cancel button is missing from text composing while sharing content through message?

我在 Swift 中使用以下代码实现了分享按钮:

@IBAction func share(_ sender: UIBarButtonItem) {
    let textToShare = [ "Text to share" ]
    let activityViewController = UIActivityViewController(activityItems: textToShare, applicationActivities: nil)
    activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash

    self.present(activityViewController, animated: true, completion: nil)
}

一切似乎都正常,但是当我通过消息共享内容时,如果我改变主意共享它,则在撰写 return 的文本中缺少取消按钮。

使用以下代码更改应用中的导航栏色调颜色:

AppDelegate didFinishLaunchingWithOptions

UINavigationBar.appearance().tintColor = UIColor.red

将红色替换为您要在按钮中设置的颜色。

我在 iOS 11 上遇到了同样的问题,这个解决方案虽然不是很好,但对我来说很好。

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UINavigationBar appearance] setTranslucent:YES];
    [[UINavigationBar appearance] setBackgroundColor:[UIColor blackColor]];
    [[UINavigationBar appearance] setTitleTextAttributes:@{
            NSForegroundColorAttributeName: [UIColor blackColor]
    }];
}

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        [[UINavigationBar appearance] setTranslucent:NO];
        //set your app color
        [[UINavigationBar appearance] setBackgroundColor:[UIColor APPCOLOR]];
        [[UINavigationBar appearance] setTitleTextAttributes:@{
                NSForegroundColorAttributeName: [UIColor APPCOLOR]
        }];
    }

PS:我也尝试 THIS 解决方案,但对我不起作用。