How to Place custom view in IOS over another view

I want to achieve following custom view over UIViewController . What is the best way to acheive it rather then using addSubview I want to use some thing better.
I previously use following but i want to use some thing better now

[self.view addSubview:NotConnected.view];

 [self.view removeFromSuperview];

enter image description here

  • In which situations do we need to write the __autoreleasing ownership qualifier under ARC?
  • How to tell ABPeoplePickerNavigationController to list only contacts that have an email address?
  • How do I create a release build in Xcode?
  • CoreData: error: (14) I/O error for database
  • Is it possible to get the 'live' current location with an iOS Simulator?
  • my table view reuse the selected cells when scroll — in SWIFT
  • I have implemented code using https://github.com/wimagguc/ios-custom-alertview.

    I didn’t prefer to use library so how is it possible to customise UIViewController over another UIViewController as shown in image above. I use

    - (IBAction)ContinueToPayment:(id)sender {
    
        PayByVC *Newpage = [[PayByVC alloc] initWithNibName:@"PayByVC" bundle:nil];
        Newpage.checkOutInfoDict=checkOutDict;
        Newpage.modalPresentationStyle   = UIModalPresentationOverCurrentContext;
        Newpage.modalTransitionStyle     = UIModalTransitionStyleCrossDissolve;
        Newpage.view.backgroundColor     = [[UIColor blackColor] colorWithAlphaComponent:.4];
        Newpage.delegate = self;
        [self presentViewController:Newpage animated:YES completion:nil];
    
    
    }
    

    To remove from super view I have used

     [self dismissViewControllerAnimated:YES completion:nil];
    

    How can I place the payby view in centre of screen in all type of screen orientation

    3 Solutions Collect From Internet About “How to Place custom view in IOS over another view”

    Use a Modal presentation with OverFullScreen mode. Set the background of the ViewController’s view to transparent and place your custom view in the center of it.

    Easiest would be to use storyboards. Create a view controller with your custom view in the center. Otherwise, you need to call view.addSubView(..) to place your custom view on the center and create the constraints accordingly.
    To present this view controller you can create a segue or by code presentViewController(...). Don’t forget to set the modalPresentationStyle to OverFullScreen.

    No library required.

    AddSubview for UIAlertView is not possible from iOS 7.

    The only way is to create a custom UIView subclass which can act as UIAlertView.

    The linked one https://github.com/wimagguc/ios-custom-alertview seems to work well. By putting proper version check one can identify to go for native UIAlertView or CustomAlertView.

    Try CRToast I have been using it in my project. Create a util class do the config there.

    +(NSDictionary *)setupAlertWithMessage:(NSString *) message withError:(BOOL) error{
        NSDictionary *options;
    
        if(error){
    
            options = @{
                        kCRToastTextKey : message,
                        kCRToastNotificationTypeKey:@(CRToastPresentationTypePush),
                        kCRToastNotificationPresentationTypeKey:@(CRToastPresentationTypePush),
                        kCRToastTextAlignmentKey : @(NSTextAlignmentCenter),
                        kCRToastBackgroundColorKey : [UIColor colorWithRed:234/255.0 green:85/255.0 blue:72/255.0 alpha:1.0],
                        kCRToastAnimationInTypeKey : @(CRToastAnimationTypeSpring),
                        kCRToastAnimationOutTypeKey : @(CRToastAnimationTypeSpring),
                        kCRToastAnimationInDirectionKey : @(CRToastAnimationDirectionTop),
                        kCRToastAnimationOutDirectionKey : @(CRToastAnimationDirectionBottom)
                        };
    
    
        }else{
            options = @{
                        kCRToastTextKey : message,
                        kCRToastNotificationTypeKey:@(CRToastPresentationTypePush),
                        kCRToastNotificationPresentationTypeKey:@(CRToastPresentationTypePush),
                        kCRToastTextAlignmentKey : @(NSTextAlignmentCenter),
                        kCRToastBackgroundColorKey :[UIColor colorWithRed:65/255.0 green:165/255.0 blue:151/255.0 alpha:1.0],
                        kCRToastAnimationInTypeKey : @(CRToastAnimationTypeSpring),
                        kCRToastAnimationOutTypeKey : @(CRToastAnimationTypeSpring),
                        kCRToastAnimationInDirectionKey : @(CRToastAnimationDirectionTop),
                        kCRToastAnimationOutDirectionKey : @(CRToastAnimationDirectionBottom)
                        };
    
        }
    
        return options;
    
       }
    

    Then import your util class where ever you need to then use it this way:

    [CRToastManager showNotificationWithOptions:[MyRateUtil setupAlertWithMessage:@"Alert!" withError:YES/NO]
                                        completionBlock:^{
    
                                        }];