ios - UIview 动画将一个 View 覆盖到另一个 View

标签 ios

我是新的 iPhone 开发人员,我在 iPad 横向模式下遇到 uiview 动画问题。我有两个 View view1(如分割 View )和 view2(覆盖剩余窗口)。当我触摸从右向左移动 view2 时,它将被覆盖view1 带有移动动画。同时,当我触摸从左向右移动时,view2 会回到原来的位置。请分享您的想法

谨致问候, 拉杰什。

最佳答案

大家好,我终于找到答案了,

- (void)viewDidLoad
{

    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [recognizer setNumberOfTouchesRequired:1];
    [secondView addGestureRecognizer:recognizer];
    [recognizer release];


    UISwipeGestureRecognizer *recognizerleft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
    [recognizerleft setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [recognizerleft setNumberOfTouchesRequired:1];
    [secondView addGestureRecognizer:recognizerleft];
    [recognizerleft release];
    [self.view addSubview:secondView];
    [super viewDidLoad];


}
//To set the frame position of the view

- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
    NSLog(@"rightSwipeHandle");


    [UIView beginAnimations:@"viewanimations" context:nil];
    [UIView setAnimationDuration:0.8];
    [UIView setAnimationDelegate:self];

    secondView.frame=CGRectMake(360, 0, 660, 768);
    [UIView commitAnimations];
}

//To set the frame position of the view
- (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
    NSLog(@"leftSwipeHandle");

    [UIView beginAnimations:@"viewanimations" context:nil];
    [UIView setAnimationDuration:0.8];
    [UIView setAnimationDelegate:self];

    secondView.frame=CGRectMake(200, 0, 858, 768);
    [UIView commitAnimations];

}

关于ios - UIview 动画将一个 View 覆盖到另一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11561687/

相关文章:

ios - FaSTLane crashlytics_path 来自 Carthage

ios - dyld : Library not loaded: @rpath/libswiftSwiftOnoneSupport. 动态库

ios - AVPlayer 连续播放

ios - 如何使IOS扩展服务器获取的数据保持最新

ios - 如何使用 IOS DJI-SDK 以编程方式从无人机下载图像

iphone - iOS Dismis 的 ViewController 堆栈

ios - NSPredicate 对多关系

iphone - 在 super 上调用协议(protocol)方法

ios - 如何在不被请求的情况下将信息从服务器发送到 iOS

ios - 复数 NSLocalizedString 中的字符串参数