0

I am using below code to share some content. When I choose whatsapp option, I am seeing white background behind the texts. I am totally lost because UIActivityController handles presenting the share dialog. Any idea how to remove the white background?

let vc = UIActivityViewController(activityItems: [text, url], applicationActivities: [])
self.present(vc, animated: true)

enter image description here

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
ugur
  • 3,604
  • 3
  • 26
  • 57
  • Are you using ChameleonFramework? I've found that this changes the colours in the sharing panel. – zazzy78 Mar 15 '18 at 11:31
  • No I dont use it. But same code works with other apps. There must be something that affects the whatsapp sharing dialog – ugur Mar 15 '18 at 13:24

1 Answers1

1

For some reason, it looks like the WhatsApp interface is applying a white background colour to UILabels. You could give this a try:

let vc = UIActivityViewController(activityItems: [text, url], applicationActivities: [])
UILabel.appearance(whenContainedInInstancesOf: [UIView.self]).backgroundColor = .clear
self.present(vc, animated: true)
zazzy78
  • 172
  • 7
  • It gives the error: `Cannot convert value of type 'UIActivityViewController' to expected element type 'UIAppearanceContainer.Type'` but I tried `UILabel.appearance(whenContainedInInstancesOf: [UIActivityViewController.self]).backgroundColor = .clear` instead but no luck. – ugur Mar 16 '18 at 07:41
  • Sorry, you should give it an instance of UIView, not a view controller. Try: `UIButton.appearance(whenContainedInInstancesOf: [UIView.self]).backgroundColor = .clear` – zazzy78 Mar 16 '18 at 07:55
  • I am using transparent UITableViewCell background. probably that is the reason. your appraoch was correct. But Label appearance inside UITableViewCell could not be set. So I changed the UITableViewCell backgrund to white. `UITableViewCell.appearance(whenContainedInInstancesOf: [UIView.self]).backgroundColor = .white` – ugur Mar 16 '18 at 09:01
  • Glad you've fixed it! – zazzy78 Mar 16 '18 at 09:16