diff --git a/Example/.DS_Store b/Example/.DS_Store index 2e57383..75ac876 100644 Binary files a/Example/.DS_Store and b/Example/.DS_Store differ diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 1df4184..231d457 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -132,6 +132,8 @@ A63A9D592309698900C17B77 /* TBWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = A63A9D572309698900C17B77 /* TBWindow.m */; }; A63A9D5C23096A5F00C17B77 /* TBWindowViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = A63A9D5A23096A5F00C17B77 /* TBWindowViewController.h */; }; A63A9D5D23096A5F00C17B77 /* TBWindowViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A63A9D5B23096A5F00C17B77 /* TBWindowViewController.m */; }; + A63A9D602309859A00C17B77 /* TBCricleView.h in Headers */ = {isa = PBXBuildFile; fileRef = A63A9D5E2309859A00C17B77 /* TBCricleView.h */; }; + A63A9D612309859A00C17B77 /* TBCricleView.m in Sources */ = {isa = PBXBuildFile; fileRef = A63A9D5F2309859A00C17B77 /* TBCricleView.m */; }; A6C1742522D5B3CC007DD285 /* AppDetailInfoController.h in Headers */ = {isa = PBXBuildFile; fileRef = A6C1742322D5B3CC007DD285 /* AppDetailInfoController.h */; }; A6C1742722D5B3D0007DD285 /* AppDetailInfoController.m in Sources */ = {isa = PBXBuildFile; fileRef = A6C1742422D5B3CC007DD285 /* AppDetailInfoController.m */; }; A6C1742A22D5B9B2007DD285 /* DetailTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = A6C1742822D5B9B2007DD285 /* DetailTableViewCell.h */; }; @@ -444,6 +446,8 @@ A63A9D572309698900C17B77 /* TBWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TBWindow.m; sourceTree = ""; }; A63A9D5A23096A5F00C17B77 /* TBWindowViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TBWindowViewController.h; sourceTree = ""; }; A63A9D5B23096A5F00C17B77 /* TBWindowViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TBWindowViewController.m; sourceTree = ""; }; + A63A9D5E2309859A00C17B77 /* TBCricleView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TBCricleView.h; sourceTree = ""; }; + A63A9D5F2309859A00C17B77 /* TBCricleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TBCricleView.m; sourceTree = ""; }; A6C1742322D5B3CC007DD285 /* AppDetailInfoController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDetailInfoController.h; sourceTree = ""; }; A6C1742422D5B3CC007DD285 /* AppDetailInfoController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDetailInfoController.m; sourceTree = ""; }; A6C1742822D5B9B2007DD285 /* DetailTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DetailTableViewCell.h; sourceTree = ""; }; @@ -779,6 +783,8 @@ A63A9D572309698900C17B77 /* TBWindow.m */, A63A9D5A23096A5F00C17B77 /* TBWindowViewController.h */, A63A9D5B23096A5F00C17B77 /* TBWindowViewController.m */, + A63A9D5E2309859A00C17B77 /* TBCricleView.h */, + A63A9D5F2309859A00C17B77 /* TBCricleView.m */, ); path = UserInterface; sourceTree = ""; @@ -1178,6 +1184,7 @@ F557CDEEF68FCBCDFC3CE295EDD95632 /* TBNetDetailController.h in Headers */, 23C5C14270C05AC25A724798A9BABE6F /* TBNetMonitorDetailController.h in Headers */, A63A9D582309698900C17B77 /* TBWindow.h in Headers */, + A63A9D602309859A00C17B77 /* TBCricleView.h in Headers */, 1709975F18A3583028B0365C1C866D99 /* TBNetMonitorManager.h in Headers */, 654C6C209931C26523C15C4E970B347F /* TBnetMonitorModel.h in Headers */, F94D46F9FF00F99F0906701D97FCA786 /* TBNetMonitorUtil.h in Headers */, @@ -1454,6 +1461,7 @@ E2D2A74B8CCE33B932866DE4850C316A /* TBMemeryUse.m in Sources */, E1F537C3F58968548B9BC3665A1C0E5E /* TBNetDetailController.m in Sources */, 7C0B30B67365F35F7F32CF588EB16691 /* TBNetMonitorDetailController.m in Sources */, + A63A9D612309859A00C17B77 /* TBCricleView.m in Sources */, 6ACFBCD7D1D17C083465FD377D5F3C9A /* TBNetMonitorManager.m in Sources */, CE3C5CF30A88491AE6C00D201FB3F5BA /* TBnetMonitorModel.m in Sources */, 156583E45000249BD8D34301CCE554D5 /* TBNetMonitorUtil.m in Sources */, diff --git a/Example/TBPerformanceView/PVViewController.m b/Example/TBPerformanceView/PVViewController.m index fee2b91..341b00b 100644 --- a/Example/TBPerformanceView/PVViewController.m +++ b/Example/TBPerformanceView/PVViewController.m @@ -19,8 +19,7 @@ - (void)viewDidLoad [super viewDidLoad]; self.view.backgroundColor = [UIColor redColor]; [[TBPerformanceBoard sharedInstance] startWorkingOnViewController:self]; - [[TBPerformanceBoard sharedInstance] open]; - // Do any additional setup after loading the view, typically from a nib. + // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning diff --git a/TBPerformanceView/Classes/TBPerformanceBoard.m b/TBPerformanceView/Classes/TBPerformanceBoard.m index 84cb8e4..22e6acc 100644 --- a/TBPerformanceView/Classes/TBPerformanceBoard.m +++ b/TBPerformanceView/Classes/TBPerformanceBoard.m @@ -17,11 +17,15 @@ //#import "TBNetReachability.h" //#import "AppDelegate.h" #import "TBBoardView.h" +#import "TBCricleView.h" + +#define kCtricleHeight 110 typedef NS_ENUM(NSInteger, PerformanceBoardType) { PB_Normarl = 0, // no button type PB_DeviceInfo, PB_Detail, + PB_Circle, }; @@ -113,8 +117,9 @@ - (void)startWorkingOnViewController:(UIViewController *)ctr { _displayLink.paused = YES; } - - [self createShowView:ctr.view]; + _type = PB_Circle; + + [self createCricleView:ctr.view]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActiveNotification:) name:UIApplicationDidBecomeActiveNotification object:nil]; @@ -183,6 +188,31 @@ - (void)pushToDetail { } } + + +// 简单数据圆形 +- (void)createCricleView:(UIView *)view{ + if (view && ![view viewWithTag:1001]) { + TBCricleView *topView = [[TBCricleView alloc] initWithFrame:CGRectMake(1, 150,kCtricleHeight, kCtricleHeight)]; + [topView setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5]]; + topView.layer.cornerRadius = 4; + topView.layer.masksToBounds = YES; + topView.tag = 1001; + + if (view) { + [view addSubview:topView]; + }else { + UIWindow *w = [[UIApplication sharedApplication] keyWindow]; + [w addSubview:topView]; + } + UILabel *l = [self labelWithFontSize:12 FontColor:[UIColor whiteColor] frame:CGRectMake(0, 0, kCtricleHeight, kCtricleHeight) Text:@""]; + l.textAlignment = NSTextAlignmentCenter; + self.topLabel = l; + [topView addSubview:l]; + } +} + +// 长条形状 方便更多数据 - (void)createShowView:(UIView *)view{ if (view && ![view viewWithTag:1001]) { TBBoardView *topView = [[TBBoardView alloc] initWithFrame:CGRectMake(1, 150, [UIScreen mainScreen].bounds.size.width - 2, self.type == PB_DeviceInfo? 50: 25)]; @@ -239,7 +269,14 @@ - (void)takeReadingsFromFps:(CGFloat)fps { _topLabel.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width - 100, 50); _topLabel.numberOfLines = 0; _topLabel.textAlignment = NSTextAlignmentCenter; - }else { + } else if (_type == PB_Circle) { + + _topLabel.frame = CGRectMake(0, 0, kCtricleHeight,kCtricleHeight); + _topLabel.numberOfLines = 0; + _topLabel.textAlignment = NSTextAlignmentCenter; + string = [NSString stringWithFormat:@"CPU:%0.2f%% \n Memory:%0.2fMb \n FPS:%0.2f \n AppVersion:%@ \n iOS : %@",cpuUse,memeryUse,fps,app_version,ios_version]; + + } else { string = [NSString stringWithFormat:@"CPU:%0.2f%%; MEMERY:%0.2fMb; FPS:%0.2f",cpuUse,memeryUse,fps]; } diff --git a/UserInterface/TBCricleView.h b/UserInterface/TBCricleView.h new file mode 100644 index 0000000..78e82fd --- /dev/null +++ b/UserInterface/TBCricleView.h @@ -0,0 +1,16 @@ +// +// TBCricleView.h +// TBPerformanceView +// +// Created by BinTong on 2019/8/18. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface TBCricleView : UIView + +@end + +NS_ASSUME_NONNULL_END diff --git a/UserInterface/TBCricleView.m b/UserInterface/TBCricleView.m new file mode 100644 index 0000000..01cf2b3 --- /dev/null +++ b/UserInterface/TBCricleView.m @@ -0,0 +1,39 @@ +// +// TBCricleView.m +// TBPerformanceView +// +// Created by BinTong on 2019/8/18. +// + +#import "TBCricleView.h" + +@interface TBCricleView () + +@property (nonatomic, assign) CGFloat left; +@property (nonatomic, assign) CGFloat top; + +@end + +@implementation TBCricleView +#pragma mark - touch delegate +-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ + UITouch *touch = [touches anyObject]; + CGPoint point = [touch locationInView:self]; + _left = point.x; + _top = point.y; +} + +-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ + UITouch *touch = [touches anyObject]; + CGPoint point = [touch locationInView:self.window]; + self.frame = CGRectMake(point.x- _left, point.y - _top, self.frame.size.width, self.frame.size.height); + CGPoint topPoint = [touch locationInView:self.window]; + // [self.boardView topView:self.boardView.window Point:topPoint]; + +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + +} + @end +