MPC"Not"ification 1.1.3

MPC"Not"ification 1.1.3

Mike Critchley维护。



  • 作者
  • Mike Critchley

#MPC"Not"ification MPC"Not"ification (Objective-C)显示类似于UILocalNotification的滑动警报。图片是可选的,在创建类时传递给类。警报标题和警报消息文本是可定制的,颜色、字体和背景颜色也是可定制的。它们将看起来像这样

Alert with image

Alert with no image

为确保警报不会级联并相互覆盖,视图只有在通知不在视图层次结构中时才会返回视图对象。因此,请不要尝试堆叠通知。

需求

  • iOS 10.0+
  • 自动引用计数

请注意,如果您正在使用iOS 9运行的0.2.1,这将是一个破坏性的更改。

安装

下载此仓库,并将MPC"Not"ification{.h/.m}文件复制到您的项目中,或者

CocoaPods

# For latest release, add this to your podfile
pod 'MPC_Notification', '~> 1.1.3'

使用方法

  1. 将.h文件导入到错误处理器类中。

  2. 实例化视图

 MPC_Notification *alert = [[MPC_Notification alloc]initWithTitle:message:alertImage:displayTime:];
  1. 根据需要自定义公共属性
@property (strong, nonatomic) UIColor * _Nullable alertTitleColor;
@property (strong, nonatomic) UIColor * _Nullable alertMessageColor;
@property (strong, nonatomic) UIFont * _Nullable alertTitleFont;
@property (strong, nonatomic) UIFont * _Nullable alertMessageFont;
@property (strong, nonatomic) UIColor * _Nullable alertBackgroundColor;
  1. 显示警报视图
  if (alert) [alert display];

不要将该警报添加到您自己的层次结构中。警报将为您做所有事情。

  1. 对于触摸或拖动事件的代理回调,订阅代理
 <MPC_NotificationDelegate>

在实例化视图中设置代理

 myNotification.delegate = self

然后实现代理方法

 -(void)userDidTapMPC_NotificationView:

**显示将在显示时间达到后自动消失。任何手势也会触发消失。

**如果您包含图像资源,请使用36 x 36的图像(3种分辨率)或单个PDF矢量图像。

默认

如果只想显示文本,则将图像参数传递为空。

传递空值作为alertTitle以显示长达两行的较长警告消息。此类将相应地居中标签。

版本更新历史

~> 0.2.0 添加了用户点击通知时的代理回调(推送到 CocoaPods 20 Sept 2017)

~> 0.2.1 通知现在在iPhoneX上显示正确,要么与顶部齐平,但显示在横幅中,要么常规高度,但横幅中向右缩进。非刘海手机类型不受此更新影响。尽情享受!(推送到 CocoaPods 16 April 2018)

~>1.1.2 这是对使用9.0兼容0.2.1用户的破例更新。除了版本更新外,1.1.2还包括一个小补丁,用于处理非刘海设备顶部安全区域内边距从0到20px的变化。

~>1.1.3 这是对iOS12的补丁更新。2018年11月8日