使用 CocoaPods 设置 InboxUI
-
在项目目录的终端中运行
pod init命令。 -
打开新创建的
Podfile。 -
在您的项目名称目标下添加 Pushwoosh 依赖项:
# Uncomment the next line to define a global platform for your project# platform: ios, ‘9.0’
target ‘MyApp’ do # Comment the next line if you don’t want to use dynamic frameworks use_frameworks!
# Pods for MyApp pod 'PushwooshInboxUI'
end- 在项目目录的终端中运行以下命令:
pod install-
打开新创建的 <your_project_name>.xcworkspace 文件。
-
完成!您已成功将 Pushwoosh InboxUI 集成到您的项目中。
添加 Pushwoosh InboxUI 代码
Anchor link to要在您的应用中显示 Inbox UI,请添加 Inbox 视图控制器:
self.navigationController?.pushViewController(PWIInboxUI.createInboxController(with: PWIInboxStyle.default()), animated: true)[self.navigationController pushViewController:[PWIInboxUI createInboxControllerWithStyle:[PWIInboxStyle defaultStyle]] animated:YES];要使 Inbox 与您的应用外观匹配,请更改 PWIInboxStyle 的参数。您可以自定义字体、背景颜色等参数。
//creating a new Inbox stylelet inboxStyle = PWIInboxStyle.customStyle(withDefaultImageIcon: UIImage.init(named: "custom_image"),textColor: UIColor.darkText,accentColor: UIColor.blue,font: UIFont.systemFont(ofSize: 17))
inboxStyle?.backgroundColor = UIColor.init(white: 1, alpha: 1)inboxStyle?.listErrorMessage = NSLocalizedString("Custom error message", comment: "Custom error message")inboxStyle?.listEmptyMessage = NSLocalizedString("Custom empty message", comment: "Custom empty message")
PWIInboxStyle.setupDefaultStyle(inboxStyle)//creating a new Inbox stylePWIInboxStyle *inboxStyle = [PWIInboxStyle customStyleWithDefaultImageIcon:[UIImage imageNamed:@"custom_image"]textColor:UIColor.darkTextColoraccentColor:UIColor.blueColorfont:[UIFont systemFontOfSize:17]];
inboxStyle.backgroundColor = [UIColor colorWithWhite:1 alpha:1];inboxStyle.listErrorMessage = NSLocalizedString(@"Custom error message", @"Custom error message");inboxStyle.listEmptyMessage = NSLocalizedString(@"Custom empty message", @"Custom empty message");
[PWIInboxStyle setupDefaultStyle:inboxStyle];要自定义 Inbox UI 样式,请参考:
有关更多详细信息,请查看 Inbox Sample。