一,效果图。

二,工程图。

三,代码。

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. CSS魔法堂:你真的理解z-index吗?

    一.前言 假如只是开发简单的弹窗效果,懂得通过z-index来调整元素间的层叠关系就够了.但要将多个弹窗间层叠关系给处理好,那么充分理解z-index背后的原理及兼容性问题就是必要的知识储备了.本文作 ...

  2. SQL Server - 把星期一(周一)当作每个星期的开始在一年中求取周数

    先感叹一句!好长时间没有更新博客了!偶尔看到一句话,觉得被电击了 - 庸人败于懒,能人败于傲! 因此,不能再懒惰了! 今天想写一个有关计算 Week Number 的函数,刚开始觉得应该很简单,凭着感 ...

  3. MySql笔记01

    用了两天的时间终于把MySql安装好了,还是很麻烦的,之所以没有选择直接安装,使用的是免安装版本,主要是想了解这个数据库的配置,这样以后就可以更好的了解它了. 登录MySql:mysql –h loc ...

  4. Winform图片拖拽与缩放

    最近做项目的时候遇到上传施工平面布置图,查看,因为图片比较大,一般的显示器分辨率无法显示全,然后还需要放大看清楚图片里面的文字内容,所以需要用到图片的拖拽与缩放功能.这里整理下具体操作. 首先新建一个 ...

  5. SQL_递归查询(复杂查询示例)

    需求: 一篇文章里有很多评论,每个评论又有很多回复评论,要求: 页面将文章展示出来,且文章的主评论按照评论时间分页展示,回复评论的评论完全展示在每个主评论下面,且按照回复时间排序 最终查询结果SQL查 ...

  6. RabbitMQ入门教程——发布/订阅

    什么是发布订阅 发布订阅是一种设计模式定义了一对多的依赖关系,让多个订阅者对象同时监听某一个主题对象.这个主题对象在自身状态变化时,会通知所有的订阅者对象,使他们能够自动更新自己的状态. 为了描述这种 ...

  7. 【吐槽】IM群里几种我认为愚蠢的提问方式

    一.“有人吗?” 你能得到一句[在,请说]的答复我就服了你,这样问的结果往往是等半天没一个人鸟你,悲观的你或者就此凄凉的退群了,感概人情冷暖的同时甚至开始怀疑人生:积极的你或者这才意识到~要不干脆说问 ...

  8. Android存储空间不足的解决办法

    安装应用时,有时会出现错误Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE,这是存储空间不足的错误,这时就只能将应用安装到SD卡,在And ...

  9. 2016弱校联盟十一专场10.5---As Easy As Possible(倍增)

    题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8506#problem/A problem description As we know, t ...

  10. No.019:Remove Nth Node From End of List

    问题: Given a linked list, remove the nth node from the end of list and return its head. For example, ...