Displaying a toast above the keyboard in Obayctive c

I wrote a function that displays a toast on UIVIewController. Toast function below

-(void)showToast:(NSString*)string
{
    MBProgressHUD *hud;
    hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.labelText = string;
    hud.margin = 10.f;
    hud.yOffset = 150.f;
    hud.removeFromSuperViewOnHide = YES;
    hud.userInteractionEnabled = NO;
    [hud hide:YES afterDelay:2];
}

Now the problem is that my toast message is hiding behind the keyboard. Can someone tell me how to show a toast above the height of the keyboard?

+4
source share
1 answer

A similar question with an answer here: MBProgressHUD position at the bottom / top of the screen

In short, use the property yOffsetfor MBProgressHUDto change its position Y.

+1
source

Source: https://habr.com/ru/post/1617737/


All Articles