Directly upload the code
#import <UIKit/> @interface ShowToastView : UIView +(void)showToastView:(UIView *)uiview WithMessage:(NSString *)message; +(void)showToastViewShort:(UIView *)uiview WithMessage:(NSString *)message; +(void)showToastViewWithCostUpload:(UIView *)uiview WithMessage:(NSString *)message; +(void)showSmallHeightToastView:(UIView *)uiview WithMessage:(NSString *)message; @end
#import "" @implementation ShowToastView //Toast prompt box+(void)showToastView:(UIView *)uiview WithMessage:(NSString *)message { UIView *showview = [[UIView alloc]init]; = [UIColor colorWithRed:0 green:0 blue:0 alpha:.3]; = CGRectMake(1, 1, 1, 1); = 5.0f; = YES; [uiview addSubview:showview]; UILabel *label = [[UILabel alloc]init]; CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)]; = CGRectMake(10, 5, , ); = message; = [UIColor whiteColor]; = 1; = [UIColor clearColor]; = [UIFont boldSystemFontOfSize:font(15)]; [showview addSubview:label]; = CGRectMake(( - - 20)/2, - -100, +20, +10); [UIView animateWithDuration:5.0 animations:^{ = 0; } completion:^(BOOL finished) { [showview removeFromSuperview]; }]; } +(void)showToastViewShort:(UIView *)uiview WithMessage:(NSString *)message { UIView *showview = [[UIView alloc]init]; = [UIColor whiteColor]; = CGRectMake(1, 1, 1, 1); = 5.0f; = YES; [uiview addSubview:showview]; UILabel *label = [[UILabel alloc]init]; CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)]; = CGRectMake(10, 5, , ); = message; = [UIColor blackColor]; = 1; = [UIColor clearColor]; = [UIFont boldSystemFontOfSize:15]; [showview addSubview:label]; = CGRectMake(( - - 20)/2, - -60, +20, +10); [UIView animateWithDuration:1 animations:^{ = 0; } completion:^(BOOL finished) { [showview removeFromSuperview]; }]; } //Put a little upwards to the Toast position of the fee receipt+(void)showToastViewWithCostUpload:(UIView *)uiview WithMessage:(NSString *)message { UIView *showview = [[UIView alloc]init]; = [UIColor colorWithRed:0 green:0 blue:0 alpha:.3]; = CGRectMake(1, 1, 1, 1); = 5.0f; = YES; [uiview addSubview:showview]; UILabel *label = [[UILabel alloc]init]; CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)]; = CGRectMake(10, 5, , ); = message; = [UIColor whiteColor]; = 1; = [UIColor clearColor]; = [UIFont boldSystemFontOfSize:font(15)]; [showview addSubview:label]; = CGRectMake(( - - 20)/2, - -100, +20, +10); [UIView animateWithDuration:3.0 animations:^{ = 0; } completion:^(BOOL finished) { [showview removeFromSuperview]; }]; } // When clicking the Start button, there is no task, but because there are too many words and the height is relatively different from the width, so it is changed to a smaller height here.+(void)showSmallHeightToastView:(UIView *)uiview WithMessage:(NSString *)message { UIView *showview = [[UIView alloc]init]; = [UIColor colorWithRed:0 green:0 blue:0 alpha:.3]; = CGRectMake(1, 1, 1, 1); = 5.0f; = YES; [uiview addSubview:showview]; UILabel *label = [[UILabel alloc]init]; CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)]; = CGRectMake(10, 0, , ); = message; = [UIColor whiteColor]; = 1; = [UIColor clearColor]; = [UIFont boldSystemFontOfSize:font(15)]; [showview addSubview:label]; = CGRectMake(( - - 20)/2, - -60, +20, -5); [UIView animateWithDuration:5.0 animations:^{ = 0; } completion:^(BOOL finished) { [showview removeFromSuperview]; }]; } @end
How to use
[ShowToastView showToastView: WithMessage:@"Error in username or password"];
The above example (sharing) of the IOS imitation Android toast prompt box is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.