一个基于导航栏之上的应用内通知视图 "TOTALLY",基于 MPNotificationView。兼容 iOS 4.3 及以上版本。
UILabels
和一个 UIImageView
仅使用以下方法调用来显示消息和相关详情文本
[CMNavBarNotificationView notifyWithText:@"Grumpy wizards" andDetail:@"make a toxic brew"];`
或使用以下方法调用来添加缩略图和自定义持续时间
[CMNavBarNotificationView notifyWithText:@"Moped Dog:"
detail:@"I have no idea what I'm doing..."
image:[UIImage imageNamed:@"mopedDog.jpeg"]
andDuration:5.0];
或如果需要使用 AFNetworking
异步加载数据
CMNavBarNotificationView* notification =
[CMNavBarNotificationView notifyWithText:@"Moped Dog:"
detail:@"I have no idea what I'm doing..."
image:nil
andDuration:5.0];
//From UIImage+AFNetworking.h:
[notification.imageView setImageWithURL:[NSURL URLWithString:@"https://dl.dropbox.com/u/361895/mopeddog.png"]];
如果您需要设置背景图像
[CMNavBarNotificationView setBackgroundImage:[UIImage imageNamed:@"aImage"]];
[CMNavBarNotificationView notifyWithText:@"Moped Dog:"
detail:@"I have no idea what I'm doing..."
image:nil
andDuration:5.0];
可以通过 blocks 实现触摸处理
[CMNavBarNotificationView notifyWithText:@"Grumpy wizards"
detail:@"make a toxic brew for the jovial queen"
andTouchBlock:^(CMNavBarNotificationView *notificationView) {
NSLog( @"Received touch for notification with text: %@", notificationView.textLabel.text );
}];
也可以通过指定一个实现了 CMNavBarNotificationViewDelegate
的 delegate,最后通过处理 kCMNavBarNotificationViewTapReceivedNotification
通知。
感谢 ekurutepe 的 MPNotificationView 项目。这个项目完全基于它。
版权(C)2013 Eduardo Pinho - Codeminer42
任何人免费获得此软件和相关文档文件(“软件”)的副本,并获得在软件上不受限制地处理软件的权利,包括但不限于使用、复制、修改、合并、出版、分发、再许可和/或出售软件副本的权利,以及允许任何人将软件提供给他们,以供他们如此行事,前提是以下条件
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
软件按“原样”提供,不提供任何形式的保证,明示或暗示,包括但不限于适销性、特定用途适用性和非侵权性保证。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任负责,无论是基于合同、侵权或其他方式,无论起源于、源于或与本软件或其使用或其他交易有关。