显示帧率、CPU 使用率、应用和 iOS 版本在状态栏之上,并通过代理报告帧率和 CPU 使用率。
简单地将 GDPerformanceMonitoring 文件夹及其文件添加到您的项目中,或者使用 CocoaPods。
您可以通过将 GDPerformanceView
添加到您的 Podfile
中来使用 CocoaPods 安装它。
platform :ios, '8.0'
use_frameworks!
target 'project_name' do
pod 'GDPerformanceView', '~> 1.3.1'
end
别忘了通过添加以下代码来导入 GDPerformanceView:
#import <GDPerformanceView/GDPerformanceMonitor.h>
用法示例
开始监控
[[GDPerformanceMonitor sharedInstance] startMonitoring];
self.performanceMonitor = [GDPerformanceMonitor alloc] init];
[self.performanceMonitor startMonitoring];
停止监控
[self.performanceMonitor stopMonitoring];
完成性能监控时调用。
[self.performanceMonitor pauseMonitoring];
配置
[self.performanceMonitor configureWithConfiguration:^(UILabel *textLabel) {
[textLabel setBackgroundColor:[UIColor blackColor]];
[textLabel setTextColor:[UIColor whiteColor]];
[textLabel.layer setBorderColor:[[UIColor blackColor] CGColor]];
}];
调用以更改外观。
[self.performanceMonitor setAppVersionHidden:YES]
[self.performanceMonitor setDeviceVersionHidden:YES];
调用以更改输出信息。
[self.performanceMonitor hideMonitoring];
调用以隐藏监控视图。
[self.performanceMonitor configureStatusBarAppearanceWithPrefersStatusBarHidden:NO preferredStatusBarStyle:UIStatusBarStyleLightContent];
[self.performanceMonitor startMonitoringWithConfiguration:^(UILabel *textLabel) {
[textLabel setBackgroundColor:[UIColor blackColor]];
[textLabel setTextColor:[UIColor whiteColor]];
[textLabel.layer setBorderColor:[[UIColor blackColor] CGColor]];
}];
代理
[self.performanceMonitor setDelegate:self];
- (void)performanceMonitorDidReportFPS:(int)fpsValue CPU:(float)cpuValue {
NSLog(@"%d %f", fpsValue, cpuValue);
}
元数据