#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController
<UIScrollViewDelegate>
{
UIView *backView;
UIScrollView *scrollerViewFirst;
UIScrollView *scrollerViewSecond;
UIImageView * imageViewBook;
UILabel *label;
UIImageView *bigImageView;
UIView *bigView;
}
@end
#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;