IOS simulates a translucent viewcontroller Presentviewcontroller implementation

Source: Internet
Author: User

Recent projects require a semi-transparent view of the modal, and many people encounter this problem, setting the background color in the target view and then discovering that the modal action ended up with a black or not translucent color.

So today to tell you the solution

-(ibaction) Avtion1: (ID) Sender {testviewcontroller * TESTVC = [Testviewcontroller new]; Self.definespresentationcontext = YES;    Self is presenting view Controller TestVC.view.backgroundColor = [uicolor colorwithred:0 green:0 blue:0 alpha:.4];    Testvc.modalpresentationstyle = Uimodalpresentationovercurrentcontext; [Self PRESENTVIEWCONTROLLER:TESTVC animated:yes completion:nil];}  
    • definespresentationcontext
/* determines which parent view controller ' s view should be presented over for presentation  S of type Uimodalpresentationcurrentcontext. If No ancestor View controller has this flag set and then the presenter would be the root view controller.*/ 
    • BackgroundColor
设置你的背景颜色
    • modalpresentationstyle
/*  Defines the transition style that will be used for this view controller when it is presented modally. Set  this property on the view controller to be presented, not the presenter.  Defaults to  UIModalTransitionStyleCoverVertical.*/

IOS simulates a translucent viewcontroller Presentviewcontroller implementation

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.