一,效果图。

二,工程图。

三,代码。

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
{
NSTimer *timer;
UIImageView *imageView1;
UIImageView *imageView2;
UIImageView *imageView3;
UIView * view1;
UIView * view2;
UIView * view3;
} @end

RootViewController.m

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. //初始化背景图
[self initBackgroundView]; } #pragma -mark -funcitons
-(void)initBackgroundView
{
//第一张图片
view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 560)];
[self.view addSubview:view1]; imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 420, 560)];
imageView1.image = [UIImage imageNamed:@"guidex1.png"];
[view1 addSubview:imageView1]; //第二张图片
view2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 560)];
[self.view addSubview:view2]; imageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 420, 560)];
imageView2.image = [UIImage imageNamed:@"guidex2.png"];
[view2 addSubview:imageView2]; //第三张图片
view3 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 560)];
[self.view addSubview:view3]; imageView3 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 520, 660)];
imageView3.image = [UIImage imageNamed:@"guidex0.png"];
[view3 addSubview:imageView3]; //开启动画事件
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(changeView) userInfo:nil repeats:NO]; }
-(void)change
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:11.0];
imageView1.frame = CGRectMake(0, 0, 320, 460);
[UIView commitAnimations];
}
-(void)change1
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:11.0];
imageView2.frame = CGRectMake(0, 0, 320, 460);
[UIView commitAnimations];
}
-(void)change2
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:11.0];
imageView3.frame = CGRectMake(0, 0, 320, 460);
[UIView commitAnimations];
}
-(void)changeView
{
imageView1.frame = CGRectMake(0, 0, 520, 660);
[self change2];
CATransition * transition = [CATransition animation];
transition.duration = 2.0;//间隔时间
transition.timingFunction = UIViewAnimationCurveEaseInOut;//减缓动画
transition.type = kCATransitionFade;//各种效果
transition.subtype = kCATransitionFromRight;
transition.delegate = self;//代理,自带方法,动画的代理都不用协议
[self.view.layer addAnimation:transition forKey:nil];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
timer = [NSTimer scheduledTimerWithTimeInterval:11.0 target:self selector:@selector(changeView1) userInfo:nil repeats:NO];
} -(void)changeView1
{
imageView2.frame = CGRectMake(0, 0, 520, 660);
[self change];
CATransition * transition = [CATransition animation];
transition.duration = 2.0;//间隔时间
transition.timingFunction = UIViewAnimationCurveEaseInOut;//减缓动画
transition.type = kCATransitionFade;//各种效果
transition.subtype = kCATransitionFromRight;
transition.delegate = self;//代理,自带方法,动画的代理都不用协议
[self.view.layer addAnimation:transition forKey:nil];
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:2];
timer = [NSTimer scheduledTimerWithTimeInterval:11.0 target:self selector:@selector(changeView2) userInfo:nil repeats:NO];
}
-(void)changeView2
{
imageView3.frame = CGRectMake(0, 0, 520, 660);
[self change1];
CATransition * transition = [CATransition animation];
transition.duration = 2.0;//间隔时间
transition.timingFunction = UIViewAnimationCurveEaseInOut;//减缓动画
transition.type = kCATransitionFade;//各种效果
transition.subtype = kCATransitionFromRight;
transition.delegate = self;//代理,自带方法,动画的代理都不用协议
[self.view.layer addAnimation:transition forKey:nil];
[self.view exchangeSubviewAtIndex:2 withSubviewAtIndex:0];
timer = [NSTimer scheduledTimerWithTimeInterval:11.0 target:self selector:@selector(changeView) userInfo:nil repeats:NO];
}
 
 

【代码笔记】iOS-首页3张图片变化的更多相关文章

  1. 笔记-iOS 视图控制器转场详解(上)

    这是一篇长文,详细讲解了视图控制器转场的方方面面,配有详细的示意图和代码,为了使得文章在微信公众号中易于阅读,seedante 辛苦将大量长篇代码用截图的方式呈现,另外作者也在 Github 上附上了 ...

  2. IOS开发笔记 IOS如何访问通讯录

    IOS开发笔记  IOS如何访问通讯录 其实我是反对这类的需求,你说你读我的隐私,我肯定不愿意的. 幸好ios6.0 以后给了个权限控制.当打开app的时候你可以选择拒绝. 实现方法: [plain] ...

  3. [置顶] 几行代码实现ofo首页小黄人眼睛加速感应转动

    最新版的ofo 小黄车的首页小黄人眼睛随重力而转动,感觉有点炫酷,学习一下吧,以下代码是在xamarin android下实现 ofo首页效果图: xamarin android实现效果: 实现思路: ...

  4. 【hadoop代码笔记】Mapreduce shuffle过程之Map输出过程

    一.概要描述 shuffle是MapReduce的一个核心过程,因此没有在前面的MapReduce作业提交的过程中描述,而是单独拿出来比较详细的描述. 根据官方的流程图示如下: 本篇文章中只是想尝试从 ...

  5. 【hadoop代码笔记】hadoop作业提交之汇总

    一.概述 在本篇博文中,试图通过代码了解hadoop job执行的整个流程.即用户提交的mapreduce的jar文件.输入提交到hadoop的集群,并在集群中运行.重点在代码的角度描述整个流程,有些 ...

  6. 【Hadoop代码笔记】目录

    整理09年时候做的Hadoop的代码笔记. 开始. [Hadoop代码笔记]Hadoop作业提交之客户端作业提交 [Hadoop代码笔记]通过JobClient对Jobtracker的调用看详细了解H ...

  7. <Python Text Processing with NLTK 2.0 Cookbook>代码笔记

    如下是<Python Text Processing with NLTK 2.0 Cookbook>一书部分章节的代码笔记. Tokenizing text into sentences ...

  8. 从iOS 11 UI Kit中谈谈iOS 11的新变化

    北京时间9月20日凌晨1点,iOS 11终于迎来了正式版的推送,相信各位小伙伴已经在第一时间进行了升级.iOS 11毫无疑问是一次大规模的系统更新,UI.系统内核.锁屏等多方面都进行了不同程度的改进. ...

  9. [学习笔记] SSD代码笔记 + EifficientNet backbone 练习

    SSD代码笔记 + EifficientNet backbone 练习 ssd代码完全ok了,然后用最近性能和速度都非常牛的Eifficient Net做backbone设计了自己的TinySSD网络 ...

  10. DW网页代码笔记

    DW网页代码笔记 1.样式.       class  插入类样式  标签技术(html)解决页面的内容样式技术(css)解决页面的外观脚本技术       解决页面动态交互问题<form> ...

随机推荐

  1. 实现UniqueAttribute唯一性约束-优化版

    我之前就写过一篇<实现UniqueAttribute唯一性约束>,虽然实现了通过调用IsValid方法可以进行唯一性验证,但有一个缺点,那就是耦合度过高,原因是里面的DB上下文对象是直接写 ...

  2. MVC中的默认Model绑定者DefaultModelBinder

    一.题外话 接续上一篇: MVC中Action参数绑定的过程 public IModelBinder DefaultBinder { get { if (this._defaultBinder == ...

  3. 如果简单的记录,就可以为这个世界创造更多的财富,那么还有什么理由不去写博客呢? — 读<<黑客与画家>> 有感

    上一次博文发文时间是2016.1.15,7个月已经过去了.最近读了一本<>的书,对我触动挺大的!里面有关于技术趋势的探讨,也有关于人生和财富的思考! 开始更新iOS122的文章的初衷是,聚 ...

  4. [Asp.net 5] Configuration-新一代的配置文件(接口定义与基础实现)

    关于配置文件的目录:[Asp.net 5] Configuration-新一代的配置文件 本系列文章讲的是asp.net 5(Asp.net VNext)中的配置文件部分,工程下载地址为:https: ...

  5. 基于<MediaElement>的WPF视频播放器(带部分特效)【2】

    一.前言       上回说到需要做放视频的使用向导,这两天公司里的老司机一直帮我答疑解惑,让这个任务变得挺顺的,真心感谢他们! 这次与[1]中的不同之处在于: (1)播放和暂停按钮集成在<Me ...

  6. 如果你恨一个程序员,忽悠他去做iOS开发

    如果你恨一个程序员,忽悠他去做iOS开发.不管他背景是cobel还是 java,送他一本iOS开发的书.这种书最好是国人写的,容易以偏概全一点,相比洋鬼子的书,更容易学到皮毛.这叫舍不得孩子套不着狼, ...

  7. 导入项目时Loading descriptor ...

    最近导入了一个项目,始终在Loading descriptor ...,很长时间都没有结束. 这是Eclipse在从java.sun.com的服务器上下载配置文件,下载速度过慢导致的,其实配置文件不是 ...

  8. MySQL: @variable vs. variable. Whats the difference?

    MySQL: @variable vs. variable. Whats the difference?   up vote351down votefavorite 121 In another qu ...

  9. Yii2框架打包成Phar包报错的经历

    以yii2为例 打包文件过程比较简单,但打包好以后简单测试yii命令,一直报错: PHP Fatal error: Uncaught yii\base\InvalidParamException: T ...

  10. EventBus简单的实现

    EventBus是最近项目用到的,也只是会些简单的功能,不过感觉功能蛮强大的.代码链接:http://download.csdn.net/detail/qq_29774291/9629346 Even ...