RFAboutView 是一个简单易用的解决方案,可以在应用程序中显示版权、支持、隐私信息,并自动为第三方 Cocoapods 的发展者提供信誉。RFAboutView 使用 AutoLayout 并适用于 iPhone 和 iPad 应用程序。
注意:这是 RFAboutView 的 Objective-C 版本。还有一个用 Swift 编写的版本,可在 这里找到。除了一些小的实现差异外,两个版本都具有相同的特性集,并且行为方式相同。
其主要特点是
MFMailComposeViewController
,(可选)预先填入有用的诊断信息,以支持:应用程序名称和版本、当前设备、当前 iOS 版本、首选设备语言。要使用 RFAboutView,导入头文件
#import "RFAboutViewController.h"`
之后,初始化一个 RFAboutViewController 并将其添加到 UINavigationController 中。必须始终在导航堆栈中使用 RFAboutViewController。以下是一个完整的示例
// First create a UINavigationController (or use your existing one).
// The RFAboutView needs to be wrapped in a UINavigationController.
UINavigationController *aboutNavigation = [UINavigationController new];
// Initialise the RFAboutView:
RFAboutViewController *aboutView = [[RFAboutViewController alloc] initWithAppName:nil appVersion:nil appBuild:nil copyrightHolderName:@"ExampleApp, Inc." contactEmail:@"[email protected]" titleForEmail:@"Contact us" websiteURL:[NSURL URLWithString:@"http://example.com"] titleForWebsiteURL:@"Our Website" andPublicationYear:nil];
// Set some additional options:
aboutView.headerBackgroundColor = [UIColor blackColor];
aboutView.headerTextColor = [UIColor whiteColor];
aboutView.blurStyle = UIBlurEffectStyleDark;
aboutView.headerBackgroundImage = [UIImage imageNamed:@"about_header_bg.jpg"];
// Add an additional button:
[aboutView addAdditionalButtonWithTitle:@"Privacy Policy" andContent:@"Here's the privacy policy"];
// Add the aboutView to the NavigationController:
[aboutNavigation setViewControllers:@[aboutView]];
// Present the navigation controller:
[self presentViewController:aboutNavigation animated:YES completion:nil];
每次您运行 pod update
或 pod install
时,Cocoapods 都会自动生成一个文件,包含项目中使用的所有 Cocoapods 的版权和许可信息。RFAboutView 使用此文件来显示致谢。要使用它,请将位于 <Project Root>/Pods/Target Support Files/Pods-<Target Name>
目录中的文件 Pods-<Target Name>-acknowledgements.plist
复制到您的项目中,并将其命名为 Acknowledgements.plist
。您还可以使用不同的名称,如果这样,请将 RFAboutViewController
的 acknowledgementsFilename
属性设置为新的名称(不带 plist 扩展名)。
为了自动化此过程,您可以在 Podfile
中添加以下片段
post_install do |installer|
require 'fileutils'
FileUtils.cp_r('Pods/Target Support Files/Pods-<Target Name>/Pods-<Target Name>-acknowledgements.plist', '<Project Dir>/Acknowledgements.plist', :remove_destination => true)
end
请注意,目录名称会根据您的项目配置和使用不同的目标而有所不同。请根据您的本地项目目录进行修改,并相应地更改代码片段。此外,请不要忘记将 Acknowledgements.plist
文件添加到您的 Xcode 项目中。
如果您想为您的应用程序本地化 RFAboutView 或要更改默认文本,可以使用示例应用程序中的 RFAboutView.strings 文件作为模板。
RFAboutView 包含许多自定义选项。查看 RFAboutViewController.h
文件以获取完整文档。
要运行示例项目,首先克隆存储库,然后从 Example 目录中运行 pod install
。
RFAboutView 需要 iOS 8.0。
RFAboutView 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile
pod "RFAboutView", '~> 1.0.4'
René Fouquet, [email protected]
查看我的博客: fouquet.me
在 Twitter 上关注我 @renefouquet
RFAboutView 在 MIT 许可下提供。查看 LICENSE 文件以获取更多信息。