esi*_*ver 18 iphone notifications toast ios
任何人都可以推荐一个库来在iOS上实现咆哮或吐司式通知吗?例如,在用户保存个人资料后,我希望通知淡入,延迟3秒,报告"个人资料已保存"并淡出.现在我有一个UIAlertView,用一个"OK"按钮中断用户的工作流程,我觉得这样做太过分了.
在Android的吐司类是什么,我期待在iOS的例子.
谢谢!
use*_*435 45
我创建了一个我认为你会发现有用的解决方案:https: //github.com/scalessec/toast
它被编写为obj-c类,实质上是将makeToast方法添加到任何UIView实例中.例如:
[self.view makeToast:@"Profile saved"
duration:2.0
position:@"bottom"];
Run Code Online (Sandbox Code Playgroud)
我这样解决了:
在viewWillAppear中添加以下行以隐藏开头的标签:
[toastLabel setHidden:TRUE];
Run Code Online (Sandbox Code Playgroud)在Button click(或其他一些事件)上添加以下代码:
toastLabel.text = @"Our toast text";
[toastLabel setHidden:TRUE];
[toastLabel setAlpha:1.0];
CGPoint location;
location.x = 160;
location.y = 220;
toastLabel.center = location;
location.x = 160;
location.y = 320;
[toastLabel setHidden:FALSE];
[UIView animateWithDuration:0.9 animations:^{
toastLabel.alpha = 0.0;
toastLabel.center = location;
}];
Run Code Online (Sandbox Code Playgroud)这个标签将"掉下来"并消失.