iOS简单好看的动画


先是用xib拖的一个界面,用代码让各个视图动起来就制作成一个简单好看的动画效果了。




最终的动画效果:





.h文件

#import <UIKit/UIKit.h>


@interface FirstAnimationViewController : UIViewController

@property (strong, nonatomic) IBOutlet UIImageView *blackBackGround;

@property (strong, nonatomic) IBOutlet UIImageView *shineImageView;

@property (strong, nonatomic) IBOutlet UIImageView *shipImageView;

@property (strong, nonatomic) IBOutlet UIImageView *grayCloud1;


@property (strong, nonatomic) IBOutlet UIImageView *grayCloud2;


@property (strong, nonatomic) IBOutlet UIImageView *blueCloud;


@property (strong, nonatomic) IBOutlet UIImageView *whiteCloud1;


@property (strong, nonatomic) IBOutlet UIImageView *whiteCloud2;



.m文件

//  FirstAnimationViewController.m

//  try_firstAnimation

//

//  Created by Bear on 15/4/23.

//  Copyright (c) 2015 Bear. All rights reserved.

//


#import "FirstAnimationViewController.h"


@interface FirstAnimationViewController ()


@end


@implementation FirstAnimationViewController


- (void)viewDidLoad {

    [super viewDidLoad];

   


}


- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    

    _shineImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);

}


- (void)viewDidAppear:(BOOL)animated

{

    [super viewDidAppear:animated];


    [self cloudAniamtion];

    [self whiteCloudAnimation];

    [self shipAniamtion];

    [self sunShineAnimation];

    [self disappearAnimation];

    

}


/*--------  光照效果动画  --------*/

- (void)sunShineAnimation

{

    _shineImageView.frame = CGRectMake(370, -5, CGRectGetWidth(_shineImageView.frame), CGRectGetHeight(_shineImageView.frame));

    

    _shineImageView.layer.anchorPoint = CGPointMake(1, 0);//设置锚点到光照图片的右上角,使它从右上角开始放大

    CAAnimationGroup * animationGroup = [CAAnimationGroup animation];

    animationGroup.removedOnCompletion = NO;

    animationGroup.fillMode = kCAFillModeForwards;//设置为动画完成后的状态

    animationGroup.duration = 1.5;

    animationGroup.repeatCount = 1;

    animationGroup.timingFunction = UIViewAnimationCurveEaseInOut;

    

    CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.xy"];

    scaleAnimation.fromValue = @0.1;//开始的大小

    scaleAnimation.toValue = @1.0;//最后的大小

    scaleAnimation.duration = 1.5;

    

    CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];

    opacityAnimation.duration = 1.5;

    opacityAnimation.removedOnCompletion = NO;

    animationGroup.animations = @[scaleAnimation, opacityAnimation];

    [_shineImageView.layer addAnimation:animationGroup forKey:@"pulse"];


}


/*--------- 船动画 ----------*/

- (void)shipAniamtion

{

    [UIView animateWithDuration:1.6 animations:^{

        _shipImageView.transform = CGAffineTransformMakeTranslation(190, 0);

    }];

}



/*----------- 云朵动画 --------------*/

//乌云动画

- (void)cloudAniamtion

{

    [UIView animateWithDuration:1.4 animations:^{

        _grayCloud1.transform = CGAffineTransformMakeTranslation(-286, 0);

        _grayCloud1.alpha = 0.5;

        _grayCloud2.transform = CGAffineTransformMakeTranslation(286, 0);

        _grayCloud2.alpha0.5;

    }];

}


//白云动画

- (void)whiteCloudAnimation

{

    [UIView animateWithDuration:1.2 animations:^{

        _blueCloud.alpha = 1;

        _blueCloud.transform = CGAffineTransformMakeTranslation(248, 0);

        _whiteCloud1.alpha = 1;

        _whiteCloud1.transform = CGAffineTransformMakeTranslation(-143, 0);

        _whiteCloud2.alpha = 1;

        _whiteCloud2.transform = CGAffineTransformMakeTranslation(-55, 0);

    }];


}


//背景消失动画

- (void)disappearAnimation

{

    [UIView animateWithDuration:1.5 animations:^{

        _blackBackGround.alpha = 0.2;

    }];

}



@end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值