Displaying a message in iOS which has the same functionality as Toast in Android

前端 未结 19 1696
逝去的感伤
逝去的感伤 2020-12-12 12:35

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 se

19条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 13:35

    You can make use of MBProgressHUD project.

    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.label.text = @"Some message...";
    hud.margin = 10.f;
    hud.yOffset = 150.f;
    hud.removeFromSuperViewOnHide = YES;
    
    [hud hideAnimated:YES afterDelay:3];
    

    enter image description here

提交回复
热议问题