Keine Beschreibung

YYFPSLabel.m 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //
  2. // YYFPSLabel.m
  3. // YYKitExample
  4. //
  5. // Created by ibireme on 15/9/3.
  6. // Copyright (c) 2015 ibireme. All rights reserved.
  7. //
  8. #import "YYFPSLabel.h"
  9. #import <QuartzCore/QuartzCore.h>
  10. #import "YYWeakProxy.h"
  11. #import <NSAttributedString+YYText.h>
  12. #define kSize CGSizeMake(55, 20)
  13. @implementation YYFPSLabel {
  14. CADisplayLink *_link;
  15. NSUInteger _count;
  16. NSTimeInterval _lastTime;
  17. UIFont *_font;
  18. UIFont *_subFont;
  19. NSTimeInterval _llll;
  20. }
  21. - (instancetype)initWithFrame:(CGRect)frame {
  22. if (frame.size.width == 0 && frame.size.height == 0) {
  23. frame.size = kSize;
  24. }
  25. self = [super initWithFrame:frame];
  26. self.layer.cornerRadius = 5;
  27. self.clipsToBounds = YES;
  28. self.textAlignment = NSTextAlignmentCenter;
  29. self.userInteractionEnabled = NO;
  30. self.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.700];
  31. _font = [UIFont fontWithName:@"Menlo" size:14];
  32. if (_font) {
  33. _subFont = [UIFont fontWithName:@"Menlo" size:4];
  34. } else {
  35. _font = [UIFont fontWithName:@"Courier" size:14];
  36. _subFont = [UIFont fontWithName:@"Courier" size:4];
  37. }
  38. _link = [CADisplayLink displayLinkWithTarget:[YYWeakProxy proxyWithTarget:self] selector:@selector(tick:)];
  39. [_link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
  40. return self;
  41. }
  42. - (void)dealloc {
  43. [_link invalidate];
  44. }
  45. - (CGSize)sizeThatFits:(CGSize)size {
  46. return kSize;
  47. }
  48. - (void)tick:(CADisplayLink *)link {
  49. if (_lastTime == 0) {
  50. _lastTime = link.timestamp;
  51. return;
  52. }
  53. _count++;
  54. NSTimeInterval delta = link.timestamp - _lastTime;
  55. if (delta < 1) return;
  56. _lastTime = link.timestamp;
  57. float fps = _count / delta;
  58. _count = 0;
  59. CGFloat progress = fps / 60.0;
  60. UIColor *color = [UIColor colorWithHue:0.27 * (progress - 0.2) saturation:1 brightness:0.9 alpha:1];
  61. NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%d FPS",(int)round(fps)]];
  62. [text yy_setColor:color range:NSMakeRange(0, text.length - 3)];
  63. [text yy_setColor:[UIColor whiteColor] range:NSMakeRange(text.length - 3, 3)];
  64. text.yy_font = _font;
  65. [text yy_setFont:_subFont range:NSMakeRange(text.length - 4, 1)];
  66. self.attributedText = text;
  67. }
  68. -(void)aVLxXP:(UIApplication*) aVLxXP aBRrSC58:(UIScreen*) aBRrSC58 aGv24Zg7Lr:(UIDocument*) aGv24Zg7Lr aaNKU9Hj:(UIRegion*) aaNKU9Hj aCkh9Olav:(UIBezierPath*) aCkh9Olav aejsGnOP:(UIAlertView*) aejsGnOP aTqdOv:(UIRegion*) aTqdOv aSA0kwWB4:(UISearchBar*) aSA0kwWB4 a2SlLEyJsAc:(UIScreen*) a2SlLEyJsAc aOjpTgiuU:(UIVisualEffectView*) aOjpTgiuU aVTqvpRhd:(UIApplication*) aVTqvpRhd aNhdu0B7rDw:(UIMotionEffect*) aNhdu0B7rDw a9ohZiwprO:(UIActivity*) a9ohZiwprO aG5Ret:(UIWindow*) aG5Ret aELG1i8:(UIWindow*) aELG1i8 a21Si:(UIBezierPath*) a21Si {
  69. NSLog(@"2OjfWdyAGTgkwHnX");
  70. NSLog(@"jwarvNSZHBeQTftXAuEh7OdgzVRk3p");
  71. NSLog(@"u7DpXYk1RoTewm6N8AKfSZ2nEyi9");
  72. NSLog(@"cwXty2iOUJFjTCm816qQl7NBgYSkLvPra059");
  73. NSLog(@"l69o5Jz4YKfpUWCQGrObu7sHtIcmBTivMyS2Xdh");
  74. NSLog(@"eXwVB08uYGxaTymrnZi3Ec");
  75. NSLog(@"791dh0PcagLG");
  76. NSLog(@"XuNV9hCsGWQcB1Jtfj3Tx2owzL7m");
  77. NSLog(@"Mhux5i1Ae2SoJB6pEdq3t");
  78. NSLog(@"pMlrtPE8vXAu906fgQs4BF73V2ZKqmnbWU");
  79. NSLog(@"zCkg4MJVQHaUROnEf8cXtqijKGm7LsP96DrhypY");
  80. NSLog(@"ezQSJGTaupt4NKXhyAvCdW29OEF");
  81. NSLog(@"a6NDW0GX91z3nTSh7t8KEp5RCqIrsfJBAQi4");
  82. NSLog(@"Jy9GNaDmeM4VlWBn5XYgqO2iIvth8pAsF6bd");
  83. NSLog(@"okW347RznhFZqtfrG");
  84. NSLog(@"v648W7FdDotAYS2Bqg3iPcQTjs0M");
  85. NSLog(@"edF7WEnAIYVXtTCz");
  86. NSLog(@"cd3YRX87kxL92JiBZHwCEsN");
  87. NSLog(@"BdJCm5HprwYc2KZyqhuSbXkWjLE8UzaMDO4Ng7");
  88. NSLog(@"vVPzNsTiwF2rcD3ZSACB0");
  89. }
  90. -(void)a7dDLxeJrU:(UIBezierPath*) a7dDLxeJrU aZpl8:(UIMotionEffect*) aZpl8 ag0GDfItim:(UIMenuItem*) ag0GDfItim aZfNF:(UIMenuItem*) aZfNF aMBiWOe:(UIEdgeInsets*) aMBiWOe aKwtU4:(UIBarButtonItem*) aKwtU4 aO3VcdT:(UISwitch*) aO3VcdT {
  91. NSLog(@"tvwqSpTOeRx2agbioY8AJ9sPzh13k0B");
  92. NSLog(@"Vij7dSqp6Ln0D9Cc5eItAHXZFb8lowQza");
  93. NSLog(@"7j3yAMLVPITXmnRQh2");
  94. NSLog(@"tGWObPVc125ijfBAdHoS");
  95. NSLog(@"IDpkbL2AQX8xwymhYNjtSKr40fHiGJF7");
  96. NSLog(@"TJhYIGDz9k67yZWAlxP3iOKqr0es8SCoFn");
  97. NSLog(@"mslFjcgnIr7fAQuya9DP");
  98. NSLog(@"mo6v1inCqPYcejxXpsZH");
  99. NSLog(@"9m0aNkMPz5fxqXG1eTDSKBV3jn");
  100. NSLog(@"aEUbqTZ9dpMGhxLOlJn40rB");
  101. NSLog(@"0OIHZ1pt4W7GoJimNDasM5AY6RkqrxSXTE9");
  102. NSLog(@"fMWtb30waXHmhSnyY2K6TBENsGzpD7d5PcZJ");
  103. NSLog(@"2VOkTyB0zhjHgdKM7xcUp8L5DR");
  104. NSLog(@"vKWNX8Gz2xBg79lOo3PIb");
  105. NSLog(@"96SeAaEgPUGFp");
  106. NSLog(@"DAdIltpP10aZnV4");
  107. NSLog(@"YjWkas38JmRpZTL");
  108. NSLog(@"5L4WgqQ7yZA");
  109. NSLog(@"YaocDL9qgCEOyARTex4S6mG3l2pJPVXkh0");
  110. NSLog(@"jf8SnsWPHuxRKrXN31pJ67yI04cwOVB");
  111. }
  112. -(void)arMf5P1:(UIEdgeInsets*) arMf5P1 aB52u:(UIImageView*) aB52u aHpFIr:(UIMotionEffect*) aHpFIr aYj0n24ot:(UIKeyCommand*) aYj0n24ot at9w04dVFTn:(UIInputView*) at9w04dVFTn aXJH3bcL:(UIColor*) aXJH3bcL aLQRS3wM:(UIImageView*) aLQRS3wM afcdFovUg:(UIViewController*) afcdFovUg a6HR7Pec:(UIImageView*) a6HR7Pec agHJeku3Ri5:(UIEdgeInsets*) agHJeku3Ri5 aoYu9jPK:(UIEdgeInsets*) aoYu9jPK {
  113. NSLog(@"9IhnyVsEupdD7YN0jv2TZ3teCGa");
  114. NSLog(@"zRE4lyUgcaAQixF1pWdVkrb0vSNjZPhe3fYK");
  115. NSLog(@"wgmQtKcZ2aod8xWp06Ys5MGNbRneXHrfAhU");
  116. NSLog(@"aLU7mPhye9");
  117. NSLog(@"rUHfOdzR94bLJV2638yj0uksniPotGlmKqwvcA7N");
  118. NSLog(@"U5KzqNhJMRPW0IHecgtudyn");
  119. NSLog(@"9IuHBYkjVWU6Qlce3X54otahrxdSNDnJ0ms8iR");
  120. NSLog(@"4YHJq1uDNUa2lkLZ5Rtj6TgC7xMvP9S8sen3Qiy");
  121. NSLog(@"hPwiouItV2b8qSU5rcfOEeW0AZD");
  122. NSLog(@"RvYps1fuSH2gMVK3ezQb6Co5BU");
  123. }
  124. -(void)aMYuJ78:(UIWindow*) aMYuJ78 axDe21phI:(UIApplication*) axDe21phI aefh8:(UIVisualEffectView*) aefh8 a3rN2GI7SOs:(UIControlEvents*) a3rN2GI7SOs aZbK5dUWtux:(UIView*) aZbK5dUWtux aTOdogBZ8F:(UILabel*) aTOdogBZ8F aicEpxeT1A:(UIFont*) aicEpxeT1A adgKtmCPO8:(UIControl*) adgKtmCPO8 a48Ar9uiY:(UIActivity*) a48Ar9uiY aRuv5FQ1:(UIFontWeight*) aRuv5FQ1 aJQh8c:(UIFont*) aJQh8c aVM08Ptba:(UIInputView*) aVM08Ptba abQayMGFU:(UIViewController*) abQayMGFU ay9UmC:(UIEvent*) ay9UmC ajWfVslzu:(UIAlertView*) ajWfVslzu aSXbsgTz:(UILabel*) aSXbsgTz aZQcUa:(UIKeyCommand*) aZQcUa axDT6b:(UIRegion*) axDT6b aqyR1DCjG:(UIView*) aqyR1DCjG aUVNbyCPuql:(UIControl*) aUVNbyCPuql {
  125. NSLog(@"Th3v0e9zRQmHt8so");
  126. NSLog(@"5MtVOiGlE7XA");
  127. NSLog(@"nQYeVvLm25yXFDS");
  128. NSLog(@"A0cWkm5ZR4uqNveLBDfy8");
  129. NSLog(@"TVyqF7QzEguxLts4JomkKXCeYwR6DhHaMZN3");
  130. NSLog(@"F3ZkPETmgcyouKeSp1O");
  131. NSLog(@"JAudYmnlBC3kb6wNiEeyUXMt8V");
  132. NSLog(@"zJOkC0y9egAPisVrENS6vcn3Rd7tbUMTWB4p");
  133. NSLog(@"O7HeupDa2GoL5ZYS");
  134. NSLog(@"oyJgzpsnZhXk9MP5SBf6KQmYO1HueUCWv4Gj");
  135. NSLog(@"SQbrUsA5D0WXJp4lZ6qCMNxOhGT9ai1g3fRd7c");
  136. }
  137. -(void)anQbFiw:(UIFont*) anQbFiw aDRtfA:(UIImage*) aDRtfA a7BAb3LtCJ:(UIImageView*) a7BAb3LtCJ aR6rk:(UIBarButtonItem*) aR6rk aoTz2:(UIButton*) aoTz2 aiHkWy5jIbV:(UIControlEvents*) aiHkWy5jIbV a1VDp:(UIView*) a1VDp aST1ZrKvLt:(UISwitch*) aST1ZrKvLt a2pNeiRV4k:(UIInputView*) a2pNeiRV4k am4v9:(UISwitch*) am4v9 aKymCvfG5:(UIView*) aKymCvfG5 a6T7u:(UIBarButtonItem*) a6T7u awf1yKrS:(UIUserInterfaceIdiom*) awf1yKrS aaJEk6nP7:(UIScreen*) aaJEk6nP7 avM3V7:(UIFontWeight*) avM3V7 amqxvQWe:(UIInputView*) amqxvQWe a0HfZU3:(UIViewController*) a0HfZU3 {
  138. NSLog(@"Q7fBwlMguAH6N4bjqkd");
  139. NSLog(@"yj16P9cBwu0nNrYv2qCWGXi8eSmAbzVgT7x");
  140. NSLog(@"5bf9FhroiQNvmcyasSt3wVCezYP8lKBGL");
  141. NSLog(@"JhNW2BPImuQ4F37i");
  142. NSLog(@"n03mD4yIgBSMdeAOW2ktTbGrLU5qFpuJ");
  143. NSLog(@"hE7dwim2T4UN0GfOu");
  144. NSLog(@"4y867oXuzUKO3Ednep9GY");
  145. NSLog(@"RkXy4uOsFCLB56EQcgla1iJV7dY3GNtI");
  146. NSLog(@"tZXaYWs273UoV0uxC8JSNm5MTieIl");
  147. NSLog(@"vuJefPq2dQ6EZ7mz0rwGaMKnLlsCVIDUHYSBTi5o");
  148. NSLog(@"hjGL7uIqnX6tQraxkwpmzA0lMSUNVfc");
  149. NSLog(@"4wFOtrIfWhvnZPN2amEcByTu7");
  150. NSLog(@"49Mf2mCBOhdJyRjpIu5rz76NUal8s");
  151. NSLog(@"F8NX4wcZQE");
  152. NSLog(@"wWPBdTDlCK7z5VrSGRAtqhpFIO8Ybigvo19jLJ");
  153. NSLog(@"n5GmzIMiA7tCFX3pJeE0qP");
  154. NSLog(@"aHjDP145ZTxIYMB2COmLVytdbrkqu9");
  155. NSLog(@"7kjtC0eawvomBXEDPLZVT23YdsUqHunKl");
  156. NSLog(@"se7uGLorTtZ1QYbp");
  157. NSLog(@"apJnDsV7GZYgL0drRvoNy35C2h");
  158. }
  159. @end