简体   繁体   English

如何使用Objective-C为两个视图设置动画

[英]How to animate two view using Objective-C

i need to develop sample animations application using objectiveC. 我需要使用objectiveC开发示例动画应用程序。

i have two buttons on two different UiView's. 我在两个不同的UiView上有两个按钮。 one view contain profile button and another view contain setting button, when click on profile button view will increase its width and height automatically settings button view also change place. 一个视图包含配置文件按钮而另一个视图包含设置按钮,当单击配置文件按钮视图时会自动增加其宽度和高度设置按钮视图也会改变位置。 and vice versa. 反之亦然。

please find below images 请找到下面的图像 在此输入图像描述

Please help me, thanks. 请帮帮我,谢谢。

I believe what you want here is a collapsible UITableView, apple has a great example here: 我相信你想要的是一个可折叠的UITableView,苹果在这里有一个很好的例子:

Table view updates 表视图更新

Otherwise all you need to do is modify the frame inside the method in this block like this: 否则,您需要做的就是修改此块中方法内的框架,如下所示:

 [UIView animateWithDuration:1.0 animations:^{
                    myView.frame = newFrame
                }];

Hope that helps. 希望有所帮助。

You can do something like this: 你可以这样做:

when the down button is pressed for profile view, then do something like this: 当按下向下按钮进行配置文件视图时,请执行以下操作:

[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        [profileView setFrame:CGRectMake(profileView.frame.origin.x, profileView.frame.origin.y, profile.frame.size.width, finalHeight)];
        [settingsView setFrame:CGRectOffset(settingsView.frame, 0, final_Y_Coordinate)];

    }completion:^(BOOL finished){
    }];

So what this basically, do is, it increases the height of profile view and simultaneously change Y-Coordinate of Settings View. 所以这基本上是,它增加了剖面视图的高度,同时改变了设置视图的Y坐标。

You can do same thing for settingsView where only height of settingsView changes. 您可以对settingsView执行相同的操作,其中只有settingsView的高度更改。

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM