如何从侧当前视图的顶部滑动的UIView(iPhone) [英] How to slide UIView from side on top of current view (iPhone)

查看:112
本文介绍了如何从侧当前视图的顶部滑动的UIView(iPhone)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有一个包含一个的MKMapView的视图。我也有一个单独的UIView(产地IB),我要滑入现有视图。

At the moment I have a view that contains an MKMapView. I also have a separate UIView (Made in IB) that I want to slide onto the existing view.

我想这样做的方法是将视图左侧滑动,而在同一时间减少了地图视图的大小。

The way I want to do this is to slide the view from the left hand side, while at the same time reducing the size of the map view.

我也想反向成为可能,这样的观点就会滑到左边,地图视图将扩大填补了国内空白。

I also want the reverse to be possible, such that the view will slide off to the left and the map view will expand to fill the gap.

,唯一的缺点是,我想这是一个很好的流畅的动画效果。我知道如何显示在顶部的UIView,然后调整地图视图,然而,这显得相当笨拙。我是你看到效果后更当上了屏幕的iAd的横幅幻灯片(但在作为UIView的屏幕上移动相同的速率调整地图视图)。

The only catch is that I want this to be a nice smooth animation. I know how to display the UIView on top and then resize the map view, however this appears quite clunky. I'm more after the effect you see when an iAd banner slides on and off the screen (but with the map view resizing at the same rate as the UIView moves on-screen).

很抱歉,如果这是一个简单的事情,这正与动画我的第一次。

Sorry if this is a simple thing to do, this is my first time working with animations.

先谢谢了。

推荐答案

的最简单的方法是使用了UIView动画的方法。事情是这样的:

The simplest way is to use the UIView animation methods. Something like this:

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    slideInView.frame = CGRectMake(0,0,320,20);
    mapView.frame = CGRectMake(0,20,320,460);
    [UIView commitAnimations];

和反向类似,但有不同的帧大小。

And the reverse is similar, but with different frame size.

这篇关于如何从侧当前视图的顶部滑动的UIView(iPhone)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆