iOS : ModalView with background transparent?
Use following snippet to do it on iOS 8 onwards:
For Objective C:
UIViewController *walkThru = [self.storyboard instantiateViewControllerWithIdentifier:@"WalkThroughScene"];
walkThru.providesPresentationContextTransitionStyle = YES;
walkThru.definesPresentationContext = YES;
[walkThru setModalPresentationStyle:UIModalPresentationOverCurrentContext];
[self.navigationController presentViewController:walkThru animated:YES completion:nil];
For Swift 2 :
let viewController : XYZViewController = self.storyboard!.instantiateViewControllerWithIdentifier(“XYZIdentifier”) as! XYZViewController
viewController.providesPresentationContextTransitionStyle = true
viewController.definesPresentationContext = true
viewController.modalPresentationStyle=UIModalPresentationStyle.OverCurrentContext
self.presentViewController(viewController, animated: true, completion: nil)
For Swift 4 :
let viewController = self.storyboard!.instantiateViewController(withIdentifier: "XYZIdentifier") as! XYZViewController
viewController.providesPresentationContextTransitionStyle = true
viewController.definesPresentationContext = true
viewController.modalPresentationStyle = .overCurrentContext
self.present(viewController, animated: true, completion: nil)
And the backgroundcolor of your presented viewController should be clearColor.
If you want your modalVC to be over the tabbar you need to define the presentation style as UIModalPresentationOverFullScreen
[_presentedViewController setModalPresentationStyle:UIModalPresentationOverFullScreen];
[_presentingViewController presentViewController:_presentedViewController animated:YES completion:nil];
you can check the iOS7 example (see my comm) or you can simple try this:
remove this line from your "presenting" method
controller.view.backgroundColor = [UIColor clearColor];
now, in viewDidLoad of the ShareController
add:
self.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
self.modalPresentationStyle = UIModalPresentationFormSheet;
PS
if you have a navigationController... use
[self.navigationController presentViewController:controller animated:YES completion:nil];