1

I have implemented share button in Swift using following code:

@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)
}

Everything seems working but when I share content through message then the cancel button is missing from text composing to return back if I change my mind sharing it. enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Maihan Nijat
  • 9,054
  • 11
  • 62
  • 110

2 Answers2

3

Change navigation bar tint color in your app using below code:

in AppDelegate didFinishLaunchingWithOptions

UINavigationBar.appearance().tintColor = UIColor.red

replace red with color that you want to set in button.

iVarun
  • 6,496
  • 2
  • 26
  • 34
0

I had the same issue on iOS 11, This solution was good for me although not excellent.

- (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: I try THIS solution also but does not work for me.

Reza Dehnavi
  • 2,256
  • 3
  • 16
  • 30