Best way to show a transparent popup on iPhone?

I am creating an iPhone 6 iOS application in Xcode 4.6, and I am wondering what is the best way to create a popup window of the following type:

Popoverscreenshot

In particular, a screenshot of the iPhone on the right, where if the user clicks on a face or UIView in the main window, a partially transparent popover appears with more detailed information, such as a portrait photo and text data, but the original view (collection of photos here) remains visible, and timers / counters keep ticking down in this view.

, iPhone Modal View , , . , , popover, . , .

presentModalViewController / , segue, loadNibNamed - , iPhone - ? , , - , , popover ( ..). , , .

, xib. , ProfileViewController.

: . popover UIView, UIViewController, UIWindow , . , , .

!

+4
4

?

enter image description here

viewControllers . vc2 childViewController of vc1 transparent. UILabel backgroundColor black alpha = 0.5.

vc2 vc2.m. :

- (IBAction)imageClick 
{
    vc2 *viewController = [[vc2 alloc]init];
    [self addChildViewController:viewController];
    viewController.view.frame = self.view.frame;
    [self.view addSubview:viewController.view];
    viewController.view.alpha = 0;
    [viewController didMoveToParentViewController:self];

    [UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^
     {
         viewController.view.alpha = 1;
     }
                     completion:nil];
}

vc2.m viewDidLoad, viewController .

self.view.backgroundColor = [UIColor clearColor];
self.view.opaque = YES;

viewController , vc2 .

, : UIView xib, , , .

category. backgroundColor UIView clearColor:

- (void)setRoundedBorder:(float) radius borderWidth:(float)borderWidth color:(UIColor*)color
{
    CALayer * l = [self layer];
    [l setMasksToBounds:YES];
    [l setCornerRadius:radius];
    // You can even add a border
    [l setBorderWidth:borderWidth];
    [l setBorderColor:[color CGColor]];
}

UILabel/UIView/UIImage, UIView , - 0,5 . xib. .

UIView

+16

// create a new view
  UIView *viewPopup=[[UIView alloc]init];
  [viewPopup setBackgroundColor:[UIColor blackColor]];
  viewPopup.alpha=0.6f;

 // add into window
 AppDelegate *appdelgateobj=(AppDelegate *)[[UIApplication sharedApplication]delegate];
 [appdelgateobj.window addSubview:viewPopup];
 [appdelgateobj.window bringSubviewToFront:viewPopup];
+7

:

1: enter image description here

2:

enter image description here

  • , , Transpertview.hidden = NO:
  • , , Transpertview.hidden = YES:

, .

+5

#import <QuartzCore/QuartzCore.h> framework .m

UIWindow* window = [UIApplication sharedApplication].keyWindow;
    self.dimView = [[UIView alloc] initWithFrame:window.bounds];
    self.dimView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.6];
    self.dimView.userInteractionEnabled = YES;
    [window addSubview:self.dimView];

dimView, .

self.searchTblContainerView = [[UIView alloc] init];
    self.searchTblContainerView.frame = CGRectMake(15, (window.frame.size.height - 300) / 2, 290, 300);
    self.searchTblContainerView.layer.cornerRadius = 15.f;
    self.searchTblContainerView.layer.borderColor = [UIColor blackColor].CGColor; /// set color as per your requirement
    self.searchTblContainerView.layer.borderWidth = 2.f;
    self.searchTblContainerView.alpha = 0.80; /// set as per your requirement 
    self.searchTblContainerView.clipsToBounds = YES;
    [self.dimView addSubview:self.searchTblContainerView];

self.searchTblContainerView - , UIControls , textField, Button .. .

self.dimView.hidden = YES; , , alertView (apple).

dimView.

self.searchTblContainerView.transform = CGAffineTransformMakeScale(0.01, 0.01);
        [UIView animateWithDuration:0.30 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
            self.searchTblContainerView.transform = CGAffineTransformIdentity;
            self.dimView.hidden = NO;
        } completion:^(BOOL finished){}];

        UIWindow* window = [UIApplication sharedApplication].keyWindow;
        [window bringSubviewToFront:self.dimView];

dimView.

 self.searchTblContainerView.transform = CGAffineTransformIdentity;
    [UIView animateWithDuration:0.30 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        self.searchTblContainerView.transform = CGAffineTransformMakeScale(0.01, 0.01);
    } completion:^(BOOL finished){
        self.dimView.hidden = YES;
    }];

, .

+1

All Articles