iOS开发中查看实时的FPS值

OttoFPSButton

前言

在项目开发中,有的时候需要查看实时的FPS值,以此作为性能的参考。

优势

  1. 实时显示FPS值。
  2. 可以拖到任意位置贴边,不影响调试。

效果图

使用效果

可随意拖动位置,不影响调试

使用

将OttoFPSButton目录拖到目标工程下,在AppDelegate.m里面加入下面代码

1
2
3
4
5
6
7
8
9
10
11
12
13
#import "OttoFPSButton.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];
CGRect frame = CGRectMake(0, 300, 80, 30);
UIColor *btnBGColor = [UIColor colorWithWhite:0.000 alpha:0.700];
OttoFPSButton *btn = [OttoFPSButton setTouchWithFrame:frame titleColor:[UIColor whiteColor] titleFont:[UIFont systemFontOfSize:15] backgroundColor:btnBGColor backgroundImage:nil];
[self.window addSubview:btn];
return YES;
}

这样就能在项目中看到FPS的状态变化了。

点我下载Demo