<s id="mvh2b"><strike id="mvh2b"><u id="mvh2b"></u></strike></s>
    1. <rp id="mvh2b"></rp>

      当前位置:首页 > IT教程

      几个简单动画代码

      时间:2021-08-09 13:54:14来源:金橙教程网 作者:admin8 阅读:89次 [手机版]
       

      动画代码

      1. UIView?

      animateWithDuration:animations:completion:

      Animate changes to one or more views using the specified duration and completion handler.

      + (void)animateWithDuration:(NSTimeInterval) duration?animations:(void (^)(void)) animations?completion:(void (^)(BOOL finished)) completion

      Parameters
      duration

      The total duration of the animations, measured in seconds. If you specify a negative value or?0, the changes are made without animating them.

      animations

      A block object containing the changes to commit to the views. This is where you Programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value. This parameter must not be?NULL.

      completion

      A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be?NULL.

      Discussion

      This method performs the specified animations imMediately using the?UIViewAnimationOptionCurveEaseInOut?andUIViewAnimationOptionTransitionNone?animation options.

      For example, if you want to fade a view until it is totally transparent and then remove it fROM your view hierarchy, you could use code similar to the following:

      [UIView animateWithDuration:0.2
           animations:^{view.alpha = 0.0;}
           completion:^(BOOL finished){ [view removeFromSuperview]; }];

      During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.)

      Availability
      • Available in iOS 4.0 and later.

      Declared In
      UIView.h

      eg:

      - (void)ShowGameButton {

      ? ?

      singleGameBt.alpha = 0;

      [UIView animateWithDuration:0.1 animations:^{ singleGameBt.alpha = 1; } completion:^(BOOL finished){ }];

      ? ?

      doubleGameBt.alpha = 0;

      [UIView animateWithDuration:0.5 animations:^{ doubleGameBt.alpha = 1; } completion:^(BOOL finished){ }];

      ? ?

      connectedGameBt.alpha = 0;

      [UIView animateWithDuration:0.9 animations:^{ connectedGameBt.alpha = 1; } completion:^(BOOL finished){ }];

      ? ?

      gameSettingBt.alpha = 0;

      [UIView animateWithDuration:1.3 animations:^{ gameSettingBt.alpha = 1; } completion:^(BOOL finished){ }];

      ? ?

      aboutBt.alpha = 0;

      [UIView animateWithDuration:1.7 animations:^{ aboutBt.alpha = 1; } completion:^(BOOL finished){ }];

      ? ?

      moreGameBt.alpha = 0;

      [UIView animateWithDuration:2.1 animations:^{ moreGameBt.alpha = 1; } completion:^(BOOL finished){ }];

      ? ?

      }

      2. UIImageView?

      animationImages

      An array of?UIImage?objects to use for an animation.

      @property(nonatomic, copy) NSArray *animationImages

      Discussion

      The array must contain?UIImage?objects. You may use the same image object more than once in the array. Setting this property to a value other than?nil?hides the image represented by the?image?property. The value of this property is?nil?by default.

      Availability
      • Available in iOS 2.0 and later.

      See Also
      • ??@property?image
      • ??@property?contentMode?(UIView)

      Declared In
      UIImageView.h

      animationDuration

      The amount of time it takes to go through one cycle of the images.

      @property(nonatomic) NSTimeInterval animationDuration

      Discussion

      The time duration is measured in seconds. The default value of this property is equal to the number of images multiplied by 1/30th of a second. Thus, if you had 30 images, the value would be 1 second.

      Availability
      • Available in iOS 2.0 and later.

      Declared In
      UIImageView.h

      animationRepeatCount

      Specifies the number of times to repeat the animation.

      @property(nonatomic) NSInteger animationRepeatCount

      Discussion

      The default value is 0, which specifies to repeat the animation indefinitely.

      Availability
      • Available in iOS 2.0 and later.

      Declared In
      UIImageView.h

      eg:

      UIImageView* campFireView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];

      campFireView.animationImages?= [NSArray?arrayWithObjects:

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo1.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo2.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo3.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo4.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo5.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo5.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo5.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo5.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo4.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo3.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo2.png"],

      ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [UIImage?imageNamed:@"logo1.png"],?nil];

      campFireView.animationDuration = 2.8;

      campFireView.animationRepeatCount = 1; ?

      [campFireView startAnimating];

      //[self.view insertSubview:campFireView atIndex:3];?

      //[self.view bringSubviewToFront:campFireView];

      [self.view addSubview:campFireView];

      3. CALayer?

      addSublayer:

      Appends the layer to the receiver’s?sublayers?array.

      - (void)addSublayer:(CALayer *) aLayer

      Parameters
      aLayer

      The layer to be added to the receiver’s?sublayers?array.

      Availability
      • Available in iOS 2.0 and later.

      Related Sample Code
      • Formulaic

      Declared In
      CALayer.h

      eg:

      // 界面加云层动画

      cloudImgview = [[UIImageView alloc]?initWithImage:[UIImage?imageNamed:@"clound.png"]];

      cloUDPoint = CGPointMake(-1.0, -1.0); ?

      cloudImgview.layer.position = CGPointMake(0,108);? // start position-->(cloudImgview)

      [self.view.layer addSublayer: cloudImgview.layer];

      [NSTimer scheduledTimerWithTimeInterval: 0.08

      ? ? ? ? ? ? ? ? ? ? ? ? ?target: self

      ? ? ? ? ? ? ? ? ? ? ? ?SELECTor: @selector(handleTimer:)

      ? ? ? ? ? ? ? ? ? ? ? ?userInfo: nil

      ? ? ? ? ? ? ? ? ? ? ? ??repeats: YES];

      //control the clound move 0.08s

      - (void) handleTimer:(NSTimer *)timer {

      CGSize size;

      CGPoint origin;

      size = [cloudImgview image].size;?

      ??// 设置cloudPoint.x == 1

      if(?cloudImgview.layer.position.x <=?((size.width / 2) + 1) - self.view.frame.origin.x?)

      cloudPoint.x = 1.0;

      // 设置origin: x递增, y不变(由image1赋值)

      if(cloudImgview.layer.position.x + (size.width / 2) + 1 >= 1520)?

      {

      origin.x = 0;

      origin.y = cloudImgview.layer.position.y;

      }else?{

      origin = cloudImgview.layer.position;

      }

      origin.x += cloudPoint.x;

      ??cloudImgview.layer.position = origin;? // 动态改变cloudImgview的坐标(x)

      ? ??/* notify the System that your view’s contents need to be redrawn */

      //[ self.view setNeedsDisplayInRect: image1.layer.frame ]; ?

      }

      相关阅读

      TOM365(影视动画)

      TOM365&#xff08;影视动画&#xff09; 链接:http://www.tom365.com/ 来自 “ ITPUB博客 ” &#xff0c;链接&#xff1a;http://blog.it

      已刻动画目录

      1. 魔卡少女樱 ? TV70 OVA 剧场 映象特典 2. 暗夜魔法使 3. GTO 4. 魔法少女奈叶 第一二三季 剧场 5. 魔神英

      cocos2d-x 序列帧动画实现人物的跑动

      前言&#xff1a; 前两篇写的文章中的角色还只是呆呆的站着现

      Ulead GIF Animator将图象文件制作成GIF动画的详细图

      Ulead GIF Animator是一款帮助用户制作动画GIF的软件。Ulead GIF Animator(GIF动画制作软件)是由友立公司出版,可将AVI文件转成动

      AE怎么制作触电效果的霓虹灯logo动画?

      ae中想要制作一个酷炫的霓虹灯logo动效,该怎么制作呢?下面我们就来看看ae制作灯光logo动画的教程。1、打开AE软件,命名霓虹灯logo动

      分享到:

      IT相关

      程序相关

      推荐文章

      热门文章

      东北老女人嫖老头视频_无遮挡H肉动漫视频在线观看_欧美牲交a欧美牲交aⅴ另类_狼人乱码无限2021芒果