适用于iOS的Growl/toast风格通知库

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)

  • 我真的很喜欢你在这里所做的一切并为我节省了一些时间,谢谢!:) +1 (2认同)

nic*_*zzz 6

我这样解决了:

  1. 在视图上创建通用标签.全屏显示,给它你需要的尺寸和中心文字.
  2. 将其位置设置在"顶部" - 此标签必须位于控件列表中的所有控件下方.
  3. 将它添加到接口,属性,合成(让我们称之为"toastLabel").
  4. 使用"toastLabel"将XIB文件关联
  5. 在viewWillAppear中添加以下行以隐藏开头的标签:

    [toastLabel setHidden:TRUE];
    
    Run Code Online (Sandbox Code Playgroud)
  6. 在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)

这个标签将"掉下来"并消失.


Pat*_*ini 5

虽然有点晚了,但这是我的看法:

https://github.com/pcperini/PCToastMessage


Kra*_*eFx 5

您可以尝试我的开源库TSMessages:https://github.com/toursprung/TSMessages

它非常易于使用,在iOS 5/6和iOS 7上也很漂亮.