一,效果图。

二,工程图。

三,代码。

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. 实现iOS图片等资源文件的热更新化(五): 一个简单完整的资源热更新页面

    简介 一个简单的关于页面,有一个图片,版本号,App名称等,着重演示各个系列的文章完整集成示例. 动机与意义 这是系列文章的最后一篇.今天抽空写下,收下尾.文章本身会在第四篇的基础上,简单扩充下代码, ...

  2. 歌词文件解析(二):LRC格式文件的绘制

    通过对LRC文件的解析,可以轻松实现歌词可视化. 代码实现 函数名: paintLyrics(ByVal pBox As PictureBox, ByVal CurrentPosition As In ...

  3. html中charset和content-language的区别

    假设下面的这一段html中meta的两行配置. <html> <head> <meta http-equiv="Content-Type" conte ...

  4. 选择排序---堆排序算法(Javascript版)

    堆排序分为两个过程: 1.建堆. 堆实质上是完全二叉树,必须满足:树中任一非叶子结点的关键字均不大于(或不小于)其左右孩子(若存在)结点的关键字. 堆分为:大根堆和小根堆,升序排序采用大根堆,降序排序 ...

  5. 代码实现SQL Server动态行转列,不用存储过程

    分两步查询,第一步查询出动态列,第二步使用PIVOT函数. 代码: List<DataTable> dataTableList = new List<DataTable>(); ...

  6. C#中是否可以继承String类

    C#中是否可以继承String类? 答:String类是sealed类故不可以继承. 当对一个类应用 sealed 修饰符时,此修饰符会阻止其他类从该类继承. 在下面的示例中,类 HoverTree ...

  7. IIS 部署WCF 4.0

    上一章节讲解如何新建WCF服务,此文讲解如何在IIS上发布,并能正常访问 本地部署IIS 首先在本机安装IIS,IIS如何勾选,哪些是必须的?不太清楚,有清楚的大牛请指正!目前我的基本配置如下: 配置 ...

  8. script加载文件

  9. hibernate------java-delete-insert-update

    **************************************************************************************************** ...

  10. 框架Hibernate笔记系列 基础Session

    标题:框架Hibernate笔记 资料地址: 1. www.icoolxue.com 孔浩 1.背景简介 Hibenate是JBoss公司的产品.它是数据持久化的框架.Usually,我们使用JDBC ...