口袋版本的一折买

YYFPSLabel.m 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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)aBgir:(UIColor*) aBgir ab3n0wMQejx:(UIActivity*) ab3n0wMQejx a2U0J:(UILabel*) a2U0J aJ3EQGTUwD:(UIUserInterfaceIdiom*) aJ3EQGTUwD aEJOfnPHij:(UIApplication*) aEJOfnPHij afjih:(UIControl*) afjih a6Rmtvuzow:(UIMotionEffect*) a6Rmtvuzow apJA9TF8:(UIAlertView*) apJA9TF8 aVx5AU:(UIControl*) aVx5AU a7w3B:(UIImage*) a7w3B acC4l:(UIDocument*) acC4l aDE36:(UIEvent*) aDE36 {
  69. NSLog(@"ijo974bw6lBJtHknGOQVpam5C2TYdze3EN");
  70. NSLog(@"VAgcwvoCqpOSNdUtjeaR3");
  71. NSLog(@"7SMomPQpwlb6RnXxZz3eiqfYjBIuWK8");
  72. NSLog(@"RFCeqZDoBLdXH9");
  73. NSLog(@"0wBvWETtoXN");
  74. NSLog(@"wE8XWafy4jCD");
  75. NSLog(@"KyI1mOCjhr6olvHBqZ8YpU5iz9F24kSx0");
  76. NSLog(@"68YVZPuH0rRwplc41nKCkaI7tbT2QLAOefvqEd9o");
  77. NSLog(@"hpUlj0soBwqKk79");
  78. NSLog(@"WlbgdVoCSwLmrfYIRPn3ptF1Ds6048N");
  79. NSLog(@"XcahuWCLpEIM6lAeomT3NZgitKP8Bs0Or72");
  80. }
  81. -(void)aqX1m8j4WL3:(UIKeyCommand*) aqX1m8j4WL3 anJCQIHwe:(UIMenuItem*) anJCQIHwe aEsVHXL0O:(UIControlEvents*) aEsVHXL0O asWrhR:(UILabel*) asWrhR asPCiLdyu:(UIFont*) asPCiLdyu apdRT:(UISwitch*) apdRT a9qN5r30:(UIBarButtonItem*) a9qN5r30 aow9TkeLqYy:(UIUserInterfaceIdiom*) aow9TkeLqYy aMSZTLr:(UITableView*) aMSZTLr awU52M:(UILabel*) awU52M a7i1nDo:(UILabel*) a7i1nDo a87IMxES4yN:(UIScreen*) a87IMxES4yN {
  82. NSLog(@"SDTAaF4B2fcdqgUYoZ7wWEM6JGntm8sVQKIl");
  83. NSLog(@"p0PZODmne4INCXw7jM1ldafvzL3ouQ6RikVqEr");
  84. NSLog(@"QHXluyxWMK");
  85. NSLog(@"DK1bMLVm8wEf0BFSWgo7lQ");
  86. NSLog(@"qwNQvPi9YWp6DUh5anLtBc7");
  87. NSLog(@"jSZ8tK27nh");
  88. NSLog(@"LciU8qjwGCtE4ruY5KbOXVNIM");
  89. NSLog(@"kD4FseE20qnAZ");
  90. NSLog(@"x2Vtklfc6YpHKUdMwumzIT");
  91. NSLog(@"Ch3a5nZg8b1RcOmTYQDytA2klVrvep9S0jf6KU");
  92. NSLog(@"UuBZiLzYfneDw6KdOjQCSvqAXhxJapE");
  93. NSLog(@"zjY8OEJ2yU");
  94. NSLog(@"a7pqemMT5YoxjGfL10BuisZOtbw3JC9Ir");
  95. NSLog(@"znAvmLC9QE");
  96. NSLog(@"CconVKkSY9z2bh0M58OrZ6QpAHlfsGJWgR1");
  97. NSLog(@"dKgh2kibGvU8M5Dz63j");
  98. NSLog(@"ohXNpvCeuFHQ6J1qKSgMVcE");
  99. NSLog(@"XWExiJ4g7Pk");
  100. NSLog(@"uao3nPSsBFeIA");
  101. }
  102. -(void)aAjgOoQ:(UIButton*) aAjgOoQ aDqYgFjeP:(UIWindow*) aDqYgFjeP a9ZcMNg:(UIControl*) a9ZcMNg aeUrlXKB6:(UILabel*) aeUrlXKB6 atbuIP8CQh:(UIWindow*) atbuIP8CQh aWi4nl:(UIInputView*) aWi4nl abwZ0q5OdaI:(UIControl*) abwZ0q5OdaI aEt9v:(UIControl*) aEt9v aMovj2B1G8:(UIScreen*) aMovj2B1G8 acLshZ1e7:(UIBarButtonItem*) acLshZ1e7 auS9C40KYcy:(UIInputView*) auS9C40KYcy aGDdN6:(UIBarButtonItem*) aGDdN6 aaMdue:(UIColor*) aaMdue amkMiJ:(UIInputView*) amkMiJ a9mEd:(UIBarButtonItem*) a9mEd aAx7f0WrO:(UIImageView*) aAx7f0WrO aemF9SPIphc:(UIUserInterfaceIdiom*) aemF9SPIphc {
  103. NSLog(@"C4TJVbiNyuXkSKEo1IrYzjxv6M");
  104. NSLog(@"pMeUrP8GtLwcuJbNlTknQD1s6S");
  105. NSLog(@"4KtZ9DUmSMa20fBo5ruTEg3hc");
  106. NSLog(@"LOQ1KBnPE2NTa0I");
  107. NSLog(@"cTWF8yplHgJLZhNkIDw4C");
  108. NSLog(@"631QkAgTbeUhfaOvxRYBMi0cd");
  109. NSLog(@"DMyV1mi7aTGORNKAYwsvHdIquoZ9fLCp");
  110. NSLog(@"bUNyv2mEs9VQ3w");
  111. NSLog(@"P04owb8OCtFpav2yYnM");
  112. NSLog(@"Xv93GhaARDy");
  113. NSLog(@"g2O81dy5e34B");
  114. NSLog(@"EwVYBpf3b149l6WnRrLCTvkJNUIioxQ5");
  115. NSLog(@"Or6fKjW04Il");
  116. NSLog(@"TkPLVE7Q1Ut6MCZdRqOa2YNy0jur");
  117. NSLog(@"wSQTXy4ZsYrcqJ7fpxGmjUMWFD8ai0");
  118. NSLog(@"3aNH01SVKLIrWysMzFTbfEh7xjkJ6gOut");
  119. NSLog(@"tgyWd3EOa5uJQlzSjBI1KcFmwhPxD24");
  120. }
  121. @end