ios – 在Obejctive c中显示键盘上方的吐司[复制]

参见英文答案 > Position MBProgressHUD at the Bottom/Top of the screen                                    5个

我编写了一个在UIVIewController上显示toast的函数.吐司功能如下

-(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];
}

现在问题是我的toast消息隐藏在键盘后面.谁能告诉我如何在键盘高度上方显示吐司?

最佳答案 类似的问题与答案在这里:

Position MBProgressHUD at the Bottom/Top of the screen

简而言之,使用MBProgressHUD的yOffset属性来更改其Y位置.

点赞