gpt4 book ai didi

ios - 如何在另一个 View 上从右向左移动一个 View

转载 作者:行者123 更新时间:2023-11-28 22:33:34 25 4
gpt4 key购买 nike

我要在我的应用程序中创建从左侧打开它的显示菜单(当我从左向右拖动时,首页从左向右移动)现在我尝试更改它但我不能。请指导我如何更改此菜单并将其放在右侧并打开此侧(从右向左拖动时)。

我的 friend ,这是我的一段代码:

#pragma mark UITouch Logic

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

if (_slideNavigationControllerState == kSlideNavigationControllerStateDrilledDown ||
_slideNavigationControllerState == kSlideNavigationControllerStateSearching)
return;

UITouch *touch = [touches anyObject];
_startingDragPoint = [touch locationInView:self.view];

if ((CGRectContainsPoint(_slideNavigationController.view.frame, _startingDragPoint))
&& _slideNavigationControllerState == kSlideNavigationControllerStatePeeking) {

_slideNavigationControllerState = kSlideNavigationControllerStateDragging;
_startingDragTransformTx = _slideNavigationController.view.transform.tx;
}

// we only trigger a swipe if either navigationBarOnly is deactivated
// or we swiped in the navigationBar
if (!kSVCSwipeNavigationBarOnly || _startingDragPoint.y <= 44.0f) {

_slideNavigationControllerState = kSlideNavigationControllerStateDragging;
_startingDragTransformTx = _slideNavigationController.view.transform.tx;

}
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

if (_slideNavigationControllerState != kSlideNavigationControllerStateDragging)
return;

UITouch *touch = [touches anyObject];

CGPoint location = [touch locationInView:self.view];

[UIView animateWithDuration:0.05f
delay:0.0f
options:UIViewAnimationOptionCurveLinear |
UIViewAnimationOptionBeginFromCurrentState
animations:^{

_slideNavigationController.view.transform = CGAffineTransformMakeTranslation(
MAX(_startingDragTransformTx + (location.x - _startingDragPoint.x),
0.0f),0.0f);

NSLog(@"%d",_slideNavigationController.view.transform);

} completion:^(BOOL finished) {

}];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

if (_slideNavigationControllerState == kSlideNavigationControllerStateDragging) {
UITouch *touch = [touches anyObject];
CGPoint endPoint = [touch locationInView:self.view];

// Check in which direction we were dragging
if (endPoint.x < _startingDragPoint.x) {
if (_slideNavigationController.view.transform.tx <= kSVCRightAnchorX) {
[self slideInSlideNavigationControllerView];
} else {
[self slideOutSlideNavigationControllerView];
}
} else {
if (_slideNavigationController.view.transform.tx >= kSVCLeftAnchorX) {
[self slideOutSlideNavigationControllerView];
} else {
[self slideInSlideNavigationControllerView];
}
}
}

}

最佳答案

你想从右到左移动 View 。最好的方法是使用滑动手势识别。单击此链接 (swipegesture)

关于ios - 如何在另一个 View 上从右向左移动一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16747722/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com