diff --git a/README.md b/README.md index 7bf89fa..c2105e1 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/XHFloatingWindow/FloatingWindowPlugin/XHDraggableButton.m b/XHFloatingWindow/FloatingWindowPlugin/XHDraggableButton.m index 3064884..48b94ce 100644 --- a/XHFloatingWindow/FloatingWindowPlugin/XHDraggableButton.m +++ b/XHFloatingWindow/FloatingWindowPlugin/XHDraggableButton.m @@ -53,7 +53,7 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesEnded:(NSSet *)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]; @@ -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; @@ -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;