pod导入相对很简单,主要讲怎么手动导入这个库
引用头文件#import "TSMessageView.h"
TSMessageNotificationType:提示样式,包含 TSMessageNotificationTypeMessage,TSMessageNotificationTypeWarning,TSMessageNotificationTypeError,TSMessageNotificationTypeSuccess,分别用来做展示信息,提示警告,提示错误,提示成功
TSMessageNotificationPosition:提示位置,包含 TSMessageNotificationPositionTop,TSMessageNotificationPositionNavBarOverlay,TSMessageNotificationPositionBottom,分别展示在顶部(有NavigationBar的话紧挨着它),遮挡NavigationBar(实际测试并不好用),底部
TSMessageNotificationDuration:提示消失方式,包含 TSMessageNotificationDurationAutomatic,TSMessageNotificationDurationEndless,含义是自动消失和手动消失
[TSMessage showNotificationWithTitle:@"标题" subtitle:@"详细信息" type:TSMessageNotificationTypeError];
[TSMessage showNotificationInViewController:self title:@"标题" subtitle:@"详细信息" image:nil type:TSMessageNotificationTypeMessage duration:TSMessageNotificationDurationAutomatic callback:nil buttonTitle:@"按钮标题" buttonCallback:^{ NSLog(@"按钮事件"); } atPosition:TSMessageNotificationPositionTop canBeDismissedByUser:YES];
可以子定义展示的样式
官方demo修改成遮挡navigationBar样式效果也不好,提示信息被NAvigationBar遮挡,但demo上有一个很好的处理思路,先把navigationbar隐藏
,待消息消失后再显示出来。
修该方法:
首先你的样式应该是:TSMessageNotificationPositionNavBarOverlay,如:
然后在if (self.navigationController.navigationBarHidden == NO) { self.navigationController.navigationBarHidden = YES; }//必须要加 [TSMessage showNotificationInViewController:self title:@"标题" subtitle:@"详细信息" image:nil type:TSMessageNotificationTypeMessage duration:TSMessageNotificationDurationAutomatic callback:nil buttonTitle:@"按钮标题" buttonCallback:^{ NSLog(@"按钮事件"); } atPosition:TSMessageNotificationPositionNavBarOverlay canBeDismissedByUser:YES];
下加入- (void)fadeOutNotification:(TSMessageView *)currentView animationFinishedBlock:(void (^)())animationFinished
if (currentView.messagePosition == TSMessageNotificationPositionNavBarOverlay) { UIViewController *vc = currentView.viewController; vc.navigationController.navigationBarHidden = NO; }