12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // SKInCallViewController+touch.m
- // SikeyComm
- //
- // Created by 刘振兴 on 2025/2/13.
- // Copyright © 2025 BaH Cy. All rights reserved.
- //
- #import "SKInCallViewController+touch.h"
- @implementation SKInCallViewController (touch)
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- //如果不在通话
- JCCallItem *activeCall = [VideoManager shared].mJuphoonCall.callItems.firstObject;
- if (!activeCall.video && activeCall.state != JCCallStateTalking)
- return;
-
- UITouch *touch = [touches anyObject];
- //当前的坐标,第一次触摸
- CGPoint point = [touch locationInView: self.view];
- self.mStartPoint = point;
-
- point = [self.smallView.layer convertPoint:point fromLayer:self.view.layer];
- if ([self.smallView.layer containsPoint:point]) {
- self.isTouchInSmallCanvas = YES;
- }
- else {
- self.isTouchInSmallCanvas = NO;
- }
- }
- - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- //如果不在通话
- JCCallItem *activeCall = [VideoManager shared].mJuphoonCall.callItems.firstObject;
- if (!activeCall.video && activeCall.state != JCCallStateTalking)
- return;
-
- if (!self.isTouchInSmallCanvas)
- return;
-
- UITouch *touch = [touches anyObject];
- CGPoint movePoint = [touch locationInView: self.view];
-
- CGPoint offsetPoint = CGPointMake(movePoint.x - self.mStartPoint.x, movePoint.y - self.mStartPoint.y);
- if (offsetPoint.x == 0 && offsetPoint.y == 0)
- return;
-
- self.isMoveInSmallCanvas = YES;
- CGRect canvasRect = self.smallView.frame;
- CGPoint endPoint = CGPointMake(canvasRect.origin.x + offsetPoint.x, canvasRect.origin.y + offsetPoint.y);
-
- //避免超框
- if (endPoint.x < 0.0) {
- endPoint.x = 0.0;
- }
- if (endPoint.y < SCREEN_STATUS_HEIGHT) {
- endPoint.y = SCREEN_STATUS_HEIGHT;
- }
- if (endPoint.x + canvasRect.size.width > SCREEN_WIDTH) {
- endPoint.x = SCREEN_WIDTH - canvasRect.size.width;
- }
- if (endPoint.y + canvasRect.size.height > SCREEN_HEIGHT) {
- endPoint.y = SCREEN_HEIGHT - canvasRect.size.height;
- }
-
- [self.smallView setOrigin:endPoint];
-
- self.mStartPoint = movePoint;
- }
- - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- //如果不在通话
- JCCallItem *activeCall = [VideoManager shared].mJuphoonCall.callItems.firstObject;
- if (!activeCall.video && activeCall.state != JCCallStateTalking)
- return;
-
- self.isTouchInSmallCanvas = NO;
- self.isMoveInSmallCanvas = NO;
- self.mStartPoint = CGPointMake(0, 0);
- }
- - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- //如果不在通话
- JCCallItem *activeCall = [VideoManager shared].mJuphoonCall.callItems.firstObject;
- if (!activeCall.video && activeCall.state != JCCallStateTalking)
- return;
-
- self.isTouchInSmallCanvas = NO;
- self.isMoveInSmallCanvas = NO;
- self.mStartPoint = CGPointMake(0, 0);
- }
- @end
|