Question about blackening the background after presentviewcontroller

Source: Internet
Author: User

Let's take a look at it first:


Use the following code to bring up a modal window and set its background transparency to 0.5. However, the background color after the prsent changes to black.

ShareVC *share = [[ShareVC alloc] init];[self presentViewController:share animated:YES completion:nil];

At first, I thought it was a problem with setting transparency or [uicolor clearcolor]. I found it was not a problem after several times. After Google, I found several reliable answers on stackoverflow ~

Why does presentmodalviewcontroller: animated: Turn the background black? Display clearcolor uiviewcontroller over uiviewcontroller:

NavigationcontrollerAndView ControllersAre designed in such a way that only one View Controller may show at a time. when a new view controller is pushed/presented the previous View Controller will be hidden by the system. so when you reduce the modal view'sAlphaYou will possibly seeWindow's backgroundcolor(Black colorYou see now ).

If you want a translucent view to slide-in over the main view, you can add the view asSubviewOf main view and animate it usingUiview animations.

Therefore, use Uiview animationsImplementation:

if (!_isShareViewOpen) { _isShareViewOpen = YES; ShareVC *shareVC = [[ShareVC alloc] initWithNibName:@"ShareVC" bundle:nil]; shareVC.shareVC = shareVC; shareVC.awardList = self; [self.view addSubview:shareVC.view]; [UIView animateWithDuration:0.75f animations:^{ shareVC.view.frame = CGRectMake(0, 640, self.view.frame.size.width, self.view.frame.size.height); shareVC.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); } completion:^(BOOL finished) { }]; }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.