How to Place custom view in IOS over another view

前端 未结 3 2051
情书的邮戳
情书的邮戳 2021-01-14 14:08

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.

3条回答
  •  不要未来只要你来
    2021-01-14 14:45

    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:^{
    
                                        }];
    

提交回复
热议问题