一,效果图。

二,工程图。

三,代码。

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. 我的vim配置文件

    强烈拥护开源精神,高举开源大旗,今天我就分享下我自己结合网上还有自己实际使用配的vimrc,可以给各位参考下,不要见笑,具体说明我在rc里写的也很详细,可以具体看下,也希望可以借这个机会能多认识认识几 ...

  2. Wamp 简单使用方法

    1.在wamp的安装目录 \bin\apache\Apache2.4.4\conf 中找到  httpd.conf文件删除 Include conf/extra/httpd-vhosts.conf 这 ...

  3. 无刷新提交表单(非Ajax实现)

    HTML代码: <iframe id="fra" name="frm" style="display: none;"></ ...

  4. asp.net动态生成按钮Button控件

    1.动态生成button控件及响应服务端和客户端事件 void BindButtons(){ foreach (var item in items) { Button Btn = new Button ...

  5. Git合并特定commits 到另一个分支

    https://ariejan.net/2010/06/10/cherry-picking-specific-commits-from-another-branch/ http://blog.csdn ...

  6. 算法:冒泡排序(python版)

    1.将n个元素从大到小排序后,选择第k个大的元素 #!/usr/bin/env python #coding -*- utf:8 -*- #冒泡排序选第k个元素 import random impor ...

  7. 框架SpringMVC笔记系列 二 传值

    主题:SpringMVC(第一节中再回顾复习一次) 学习资料参考网址: 1.http://www.icoolxue.com 2.http://haohaoxuexi.iteye.com/blog/13 ...

  8. 【FOL】第九周

    不知不觉又是三周过去了. 这几周忙了一下,其他时间全都在搞服务端,简直是酸爽的不行...不过还好出了些成果. 目前服务端有: 1.版本服务:游戏版本更新 2.账号服务:用户身份验证,返回各种连接(代理 ...

  9. mysql易混淆知识点

    1,join 和 union join连接属于表之间的水平操作,而union 是表之间的垂直操作.简单讲就是水平操作主要是为了获得列数据,垂直操作是为了获得行数据 cross  join        ...

  10. 使用loadrunner进行压力测试之----post请求

    1. 发送post请求时使用web_submit_data 如: web_submit_data("create",//事务名 "Action=http://bizhi. ...