一,效果图。

二,工程图。

三,代码。

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
<UIScrollViewDelegate>
{
UIView *backView;
UIScrollView *scrollerViewFirst;
UIScrollView *scrollerViewSecond;
UIImageView * imageViewBook;
UILabel *label;
UIImageView *bigImageView;
UIView *bigView;
} @end

RootViewController.m

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. [self initBackgroundView];
}
#pragma -mark -funcitons
-(void)initBackgroundView
{
//放大的时候,底部的图
bigView = [[UIView alloc]initWithFrame:CGRectMake(10, 10, 300, 440)];
[self.view addSubview:bigView]; //背景图
backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 460)];
[self.view addSubview:backView]; //背景
UIImageView * imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"backImage.png"]];
imageView.frame = CGRectMake(0, 0, 320, 460);
[backView addSubview:imageView]; //scrollerViewFrist
scrollerViewFirst = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 151)];
scrollerViewFirst.contentSize = CGSizeMake(320 * 4, 151);
scrollerViewFirst.contentOffset = CGPointMake(0, 0);
scrollerViewFirst.bounces = YES;
scrollerViewFirst.alwaysBounceHorizontal = YES;
scrollerViewFirst.showsHorizontalScrollIndicator = NO;
scrollerViewFirst.pagingEnabled =YES;
scrollerViewFirst.delegate = self;
scrollerViewFirst.tag=1;
scrollerViewFirst.backgroundColor=[UIColor redColor];
[backView addSubview:scrollerViewFirst]; //scrollerViewSecond
scrollerViewSecond = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 152, 320, 308)];
scrollerViewSecond.contentSize = CGSizeMake(320 * 4, 308);
scrollerViewSecond.contentOffset = CGPointMake(0, 0);
scrollerViewSecond.bounces = YES;
scrollerViewSecond.alwaysBounceHorizontal = YES;
scrollerViewSecond.showsHorizontalScrollIndicator = YES;
scrollerViewSecond.delegate = self;
scrollerViewSecond.pagingEnabled =YES;
scrollerViewSecond.backgroundColor=[UIColor orangeColor];
[backView addSubview:scrollerViewSecond]; //scrollerFirst的大的背景图
for (int i = 0; i < 4;i++) {
for ( int j = 0; j < 3; j++) {
UIImageView * imageview = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"scrollerFirstTop.png"]]];
imageview.frame = CGRectMake(0 + i* 320, 0, 320, 151);
[scrollerViewFirst addSubview:imageview];
}
} //scrollerFirst书架上的图集
for ( int i = 0; i < 12; i++) { imageViewBook = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d.png",i+1]]];
imageViewBook.contentMode = UIViewContentModeScaleToFill;
imageViewBook.frame = CGRectMake((10 + i * 106 ) , 22, 80, 100);
imageViewBook.userInteractionEnabled = YES;
imageViewBook.tag = i; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doClickTapGesture:)];
[imageViewBook addGestureRecognizer:tapGesture]; [scrollerViewFirst addSubview:imageViewBook];
} //scrollerSecond的标题
for (int i = 0; i < 4; i++) { UIImageView *topImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"scrollerSecondTop"]];
topImageView.frame = CGRectMake(100 + 320 *i , -40 , 220, 100);
[scrollerViewSecond addSubview:topImageView]; UIImageView *titleImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"scrollerSecondTitle.png"]];
titleImageView.frame = CGRectMake(3 + 320 *i, 20, 100, 55);
[scrollerViewSecond addSubview:titleImageView];
} //scrollerViewSecond每个里面的线
for (int i = 0; i < 4;i++) {
for ( int j = 0; j < 3; j++) {
label = [[UILabel alloc]initWithFrame:CGRectMake(320*i , 80 + 60 *j, 320, 20)];
if (i==0) {
label.backgroundColor=[UIColor redColor];
}else if (i==1){
label.backgroundColor=[UIColor greenColor];
}else if (i==2){
label.backgroundColor=[UIColor blackColor];
}else if (i==3){
label.backgroundColor=[UIColor blueColor];
}
[label setFont:[UIFont systemFontOfSize:12]];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor blueColor];
[scrollerViewSecond addSubview:label]; }
} }
#pragma -mark -doClickAction
-(void)doClickTapGesture:(UITapGestureRecognizer *)tapGesture
{
NSLog(@"doClickTapGesture"); //一个页面从右侧翻转过来的效果
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
[UIView commitAnimations]; bigImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%ld.png",tapGesture.view.tag +1]]];
bigImageView.frame = CGRectMake(0,0,300, 440);
bigImageView.userInteractionEnabled = YES; UITapGestureRecognizer * tgrBig = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(beginSmall:)];
[bigImageView addGestureRecognizer:tgrBig]; bigView.alpha = 0.2; UIScrollView *scrollerViewThree = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 300, 440 )];
scrollerViewThree.delegate = self;
scrollerViewThree.maximumZoomScale = 3.0;
scrollerViewThree.minimumZoomScale = 1;
[bigView addSubview: scrollerViewThree];
[scrollerViewThree addSubview:bigImageView]; }
-(void)beginSmall:(UIGestureRecognizer *)sender
{ NSLog(@"--doClickbeginSmall--"); [UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations]; bigView.alpha = 1; [bigImageView removeFromSuperview]; }
 
 

【代码笔记】iOS-两个滚动条,上下都能滑动的更多相关文章

  1. iOS开发笔记-两种单例模式的写法

    iOS开发笔记-两种单例模式的写法   单例模式是开发中最常用的写法之一,iOS的单例模式有两种官方写法,如下: 不使用GCD #import "ServiceManager.h" ...

  2. Masonry -- 使用纯代码进行iOS应用的autolayout自适应布局

    简介 简化iOS应用使用纯代码机型自适应布局的工作,使用一种简洁高效的语法替代NSLayoutConstraints. 项目主页: Masonry 最新示例: 点击下载 项目简议: 如果再看到关于纯代 ...

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

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

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

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

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

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

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

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

  7. Masonry — 使用纯代码进行iOS应用的autolayout自适应布局

    本文转载至   http://www.ios122.com/2015/09/masonry/ 简化iOS应用使用纯代码机型自适应布局的工作,使用一种简洁高效的语法替代NSLayoutConstrain ...

  8. iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建

    1. Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated. ...

  9. iOS 两种不同的图片无限轮播

    代码地址如下:http://www.demodashi.com/demo/11608.html 前记 其实想写这个关于无限轮播的记录已经很久很久了,只是没什么时间,这只是一个借口,正如:时间就像海绵, ...

随机推荐

  1. DirectoryHelper

    /// <summary> /// 将相对路径转换成程序所在的绝对路径 /// </summary> /// <param name="path"&g ...

  2. 【Swift学习】Swift编程之旅---方法(十五)

    在Swift中结构体和枚举也能够定义方法,而在 Objective-C 中,类是唯一能定义方法的类型. 实例方法 实例方法是属于某个特定类.结构体或者枚举类型实例的方法,实例方法提供访问和修改实例属性 ...

  3. Sandcastle帮助文档生成器使用介绍

    一.软件介绍       Sandcastle是一个管理类库的文档编译器,是用于编译发布组件(Assembly)信息的一个工具,这个工具通过反射和Xslt技术,可以从dll文件及其xml注释(命令行编 ...

  4. javascript日期验证:填写的日期大于等于当前日期

    <script> $(function () { var d = new Date(); var strDate = getDateStr(d); $("#beginTime&q ...

  5. iOS阶段学习第三天笔记(运算符)

    iOS学习(C语言)知识点整理笔记 1.运算符 一.算术运算符 1)表达式由变量.常量.运算符构成,有确定的类型和值 2)算术运算符包括: +(加),-(减),*(乘),/(除),%(模) 3)算术运 ...

  6. 自己动手,让Entity Framework Power Tools在VS2015重放光彩

    Entity Framework Power Tools是一个由EntityFramework开发小组提供的工具,它可以从现有数据库生成Fluent款式的Code First代码. VS Galler ...

  7. TreeView使用

    1.添加节点,实现拖拽功能 private void Form1_Load(object sender, EventArgs e) { TreeNode node1 = new TreeNode(); ...

  8. python signal(信号)

    信号的概念 信号(signal)--     进程之间通讯的方式,是一种软件中断.一个进程一旦接收到信号就会打断原来的程序执行流程来处理信号. 几个常用信号: SIGINT     终止进程  中断进 ...

  9. 配置云服务器 FTP 服务

    自己配置的环境: OS: 阿里云 CentOS 6.5 >>Begin: 1. 登录到阿里云服务器(如何登录阿里云服务器), 在root权限下, 通过如下命令安装 vsftp [root@ ...

  10. windows / linux系统中,端口被占用解决方法

    一.在windows操作系统中,查询端口占用和清除端口占用的程序 提升权限后用:netstat -b或用 1.查询端口占用的进程ID 点击"开始"-->"运行&qu ...