作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我要在我的应用程序中创建从左侧打开它的显示菜单(当我从左向右拖动时,首页从左向右移动)现在我尝试更改它但我不能。请指导我如何更改此菜单并将其放在右侧并打开此侧(从右向左拖动时)。
我的 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/
我是一名优秀的程序员,十分优秀!