Skip to content

Commit

Permalink
修复悬浮按钮抖动bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonHu committed Jun 22, 2022
1 parent 3791158 commit 125756c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion HDWindowLogger.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'HDWindowLogger'
s.version = '2.1.1'
s.version = '2.1.2'
s.license= { :type => "MIT", :file => "LICENSE" }
s.summary = 'The iOS side displays the output log log on the screen, and can generate log file sharing, which is convenient for debugging information'
s.homepage = 'https://github.com/DamonHu/HDWindowLogger'
Expand Down
Binary file not shown.
57 changes: 50 additions & 7 deletions HDWindowLogger/HDWindowLogger/HDWindowLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,23 @@ - (void)p_share {
}

- (void)p_touchMove:(UIPanGestureRecognizer*)p {
CGPoint panPoint = [p locationInView:[[UIApplication sharedApplication] keyWindow]];
UIWindow *window = [self p_getCurrentWindow];
CGPoint panPoint = [p locationInView: window];
if (p.state == UIGestureRecognizerStateChanged) {
self.mFloatWindow.center = CGPointMake(panPoint.x, panPoint.y);
[p setTranslation:CGPointMake(0, 0) inView:self.mFloatWindow];
} else if (p.state == UIGestureRecognizerStateEnded || p.state == UIGestureRecognizerStateCancelled) {
CGFloat x = 50;
if (panPoint.x > window.bounds.size.width / 2.0) {
x = window.bounds.size.width - 50;
}
CGFloat y = MIN(MAX(120, panPoint.y), window.bounds.size.height - 140);
[p setTranslation:CGPointMake(0, 0) inView:self.mFloatWindow];
[UIView animateWithDuration:0.35 animations:^{
self.mFloatWindow.center = CGPointMake(x, y);
}];
}

}

///更新筛选查找的数据
Expand Down Expand Up @@ -467,17 +480,47 @@ - (void)p_decrypt {
[self.mTableView reloadData];
}

- (UIViewController *)p_getCurrentVC {
- (UIWindow *)p_getCurrentWindow {
UIWindow * window = [[UIApplication sharedApplication] keyWindow];
if (window.windowLevel != UIWindowLevelNormal) {
NSArray *windows = [[UIApplication sharedApplication] windows];
for(UIWindow * tmpWin in windows) {
if (tmpWin.windowLevel == UIWindowLevelNormal) {
window = tmpWin;
if (@available(iOS 13.0, *)) {
for (UIWindowScene *windowScene in [UIApplication sharedApplication].connectedScenes) {
if (windowScene.activationState == UISceneActivationStateForegroundActive) {
window = windowScene.windows.firstObject;
for (int i = 0; i<windowScene.windows.count; i++) {
UIWindow *tempWin = [windowScene.windows objectAtIndex:i];
if (tempWin.windowLevel == UIWindowLevelNormal) {
window = tempWin;
break;
}
}
break;
}
}
}
if (window == nil || window.windowLevel != UIWindowLevelNormal) {
for (int i = 0; i<[UIApplication sharedApplication].windows.count; i++) {
UIWindow *tempWin = [[UIApplication sharedApplication].windows objectAtIndex:i];
if (tempWin.windowLevel == UIWindowLevelNormal) {
window = tempWin;
break;
}
}
}
return window;
}

- (UIViewController *)p_getCurrentVC {
// UIWindow * window = [[UIApplication sharedApplication] keyWindow];
// if (window.windowLevel != UIWindowLevelNormal) {
// NSArray *windows = [[UIApplication sharedApplication] windows];
// for(UIWindow * tmpWin in windows) {
// if (tmpWin.windowLevel == UIWindowLevelNormal) {
// window = tmpWin;
// break;
// }
// }
// }
UIWindow * window = [self p_getCurrentWindow];
UIViewController *result = nil;
if ([window subviews].count>0) {
UIView *frontView = [[window subviews] objectAtIndex:0];
Expand Down

0 comments on commit 125756c

Please sign in to comment.