显示在iOS中的消息具有相同的功能吐司Android中吐司、消息、功能、iOS

2023-09-05 06:00:40 作者:感情这是我扔掉的垃圾

我需要知道是否有在iOS中其行为类似于Android的吐司消息的任何方法。也就是说,我需要显示这是几秒钟后自动关闭的消息。这是类似于吐司类的在Android环境的功能。

I need to know if there is any method in iOS which behaves like Toast messages in Android. That is, I need to display a message which is dismissed automatically after few seconds. This is similar to the functionality of the Toast class in the Android environment.

推荐答案

您可以使用 MBProgressHUD 项目。

You can make use of MBProgressHUD project.

使用HUD模式 MBProgressHUDModeText 的面包般的行为,

Use HUD mode MBProgressHUDModeText for toast-like behaviour,

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Configure for text only and offset down
hud.mode = MBProgressHUDModeText;
hud.labelText = @"Some message...";
hud.margin = 10.f;
hud.yOffset = 150.f;
hud.removeFromSuperViewOnHide = YES;

[hud hide:YES afterDelay:3];

希望帮助!