2017-06-02 22 views
4

UIActivityViewControllerを作成していて、共有メッセージのアイコンをタップした後にテキストの色を変更しようとしています。デフォルトではUIActivityViewControllerナビゲーションバーのテキストの色を変更します。

、私はそれをデフォルト(つまり、黒のタイトルテキスト、および青Cancel作りたいだけUIActivityViewControllerためしかしそう

UINavigationBar.appearance().tintColor = whiteColor 
UIBarButtonItem.appearance().tintColor = whiteColor 

ようAppDelegateに白に私のナビゲーションバーのテキストの色を設定しましたボタン)私は運に次のことを試してみました

let shareText = "text to share" 
let activityViewController = UIActivityViewController(activityItems: [shareText], applicationActivities: []) 

activityViewController.navigationController?.navigationBar.tintColor = UIColor.black 
activityViewController.navigationController?.navigationItem.rightBarButtonItem?.tintColor = UIColor.blue 

present(activityViewController, animated: true, completion: nil) 

結果はまだ同じWiあります白いテキスト:

画像をよく見ると、ナビゲーションバーのタイトルバーと右バーボタンの項目に白いテキストが表示されます。

enter image description here

+1

使用UINavigationBar.appearance()が存在し、UINavigationBar.appearanceながらtintColor =黒。 ().tintColor = whiteColorを終了します。 – KKRocks

+0

存在するかどうかはどのように判断するのですか? – Simon

+0

色を決定するために必要なものは? – KKRocks

答えて

1

IOSの11であなたが設定して "メッセージ画面を介して共有" のボタンの色をキャンセル変更することができる:

UIButton.appearance(whenContainedInInstancesOf: [UINavigationBar.self]).tintColor = .blue 
関連する問題