Skip to content

Commit

Permalink
完美适配iphone和ipad;
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangxh1992 committed Oct 9, 2018
1 parent 2a2cc4c commit 2edd70e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# XHFloatWindow
slight floating window plugin for iOS apps(iPhone only)
slight floating window plugin for iOS apps

![](http://img.blog.csdn.net/20161110170919449?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)

Expand Down
12 changes: 6 additions & 6 deletions XHFloatingWindow/FloatingWindowPlugin/XHDraggableButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint curPoint = [touch locationInView:_rootView];
curPoint = [self ConvertDir:curPoint];
if(IS_IPHONE) curPoint = [self ConvertDir:curPoint];
// if the start touch point is too close to the end point, take it as the click event and notify the click delegate
if (pow((_touchStartPosition.x - curPoint.x),2) + pow((_touchStartPosition.y - curPoint.y),2) < 1) {
[self.buttonDelegate dragButtonClicked:self];
Expand All @@ -74,9 +74,9 @@ -(void)buttonAutoAdjust:(CGPoint)curPoint {
}
// distances to the four screen edges
CGFloat left = curPoint.x;
CGFloat right = W - curPoint.x;
CGFloat right = IS_IPHONE ? (W - curPoint.x) : (xh_ScreenW - curPoint.x);
CGFloat top = curPoint.y;
CGFloat bottom = H - curPoint.y;
CGFloat bottom = IS_IPHONE ? (H - curPoint.y) : (xh_ScreenH - curPoint.y);
// find the direction to go
xh_FloatWindowDirection minDir = xh_FloatWindowLEFT;
CGFloat minDistance = left;
Expand Down Expand Up @@ -130,15 +130,15 @@ - (void)buttonRotate {
break;
case xh_Change2Left:
self.transform = _originTransform;
self.transform = CGAffineTransformMakeRotation(-M_PI_2);
self.transform = CGAffineTransformMakeRotation(-90*M_PI/180.0);
break;
case xh_Change2Right:
self.transform = _originTransform;
self.transform = CGAffineTransformMakeRotation(M_PI_2);
self.transform = CGAffineTransformMakeRotation(90*M_PI/180.0);
break;
case xh_Change2Upside:
self.transform = _originTransform;
self.transform = CGAffineTransformMakeRotation(M_PI);
self.transform = CGAffineTransformMakeRotation(180*M_PI/180.0);
break;
default:
break;
Expand Down

0 comments on commit 2edd70e

Please sign in to comment.