单击iPhone上的添加加号按钮时,如何制作上下动画?

问题描述

| 单击iPhone上的添加(加号)按钮时,如何制作从上到下或从上到下的动画?     

解决方法

如果您正在寻找\“ Built In \” API,那么Alex是正确的。而且效果很好。 如果您想了解如何制作自己的动画,可以在“核心动画”中选择几个选项 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html 但是一个很好的起点就是
UIView animateWithDuration
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html 您还应该了解CGAffineTransform 放在一起,这是一个将视图从右下角滑动到屏幕上,同时使其淡入的示例。 (我真的不知道我想这样做的情况,但这只是一个例子)。 我将其放在应用程序委托中,因此可以轻松地将其“粘贴”到新项目中。通常,您不会将任何这种性质的视图直接放入窗口中。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.


    UIWindow *w = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];;
    self.window = w; //property defined in the .h file
    [w release];




    UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0,100,100)];
    v.backgroundColor = [UIColor redColor];
    v.center=self.window.center;
    v.alpha=0;
    [self.window addSubview:v];

    //if you ran the code to here,you would see a square in the center of the window.
    //now lets move the square off  (off screen)  with a transform and then animate it back (on screen)

    CGAffineTransform t = CGAffineTransformMakeTranslation(160+50,240+50); //place the view just off screen,bottom right
    v.transform=t;

    //if you ran the code to here,you wouldnt see anything as the squre is placed just off screen,bottomr right

    [UIView animateWithDuration:.5  //make the animation last .5 seconds
                          delay:.3  //wait .3 seconds before performing the animation
                        options:UIViewAnimationOptionCurveEaseOut  //slow down as it reaches its destination
                     animations:^
     {
         v.transform=CGAffineTransformIdentity; //reset any transformation
         v.alpha=1.0; //fade it in

     }
                     completion:^(BOOL finished){} //nothing to do when it completes
     ];



    [self.window makeKeyAndVisible];
    return YES;
}
    ,我认为您正在考虑presentModalViewController;您可以使用它来显示一个新屏幕,该屏幕从屏幕底部向上滑动。     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...