//引导
#import "ViewController.h"
#import "MainViewController.h"
@interface ViewController ()
{
NSArray*imgArr;
UIScrollView *scv;
UIPageControl *page;
NSTimer*timer;
intk;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(change) userInfo:nil repeats:YES];
imgArr = @[@"1",@"2",@"3",@"4"];
//新特性界面
//滚动视图
scv = [[UIScrollView alloc]initWithFrame:self.view.frame];
//上颜色
scv.backgroundColor = [UIColor purpleColor];
//设置滚动范围
scv.contentSize = CGSizeMake(self.view.frame.size.width *4, self.view.frame.size.height);
//初始化图片
for(inti=0; i<4; i++)
{
UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake(i*self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.height)];
//设置分页
scv.pagingEnabled = YES;
//隐藏水平滚动条
scv.showsHorizontalScrollIndicator = NO;
//取消弹簧效果
scv.bounces=NO;
//设置滚动视图的代理
scv.delegate=self;
//设置图片
imgV.image= [UIImageimageNamed:imgArr[i]];
[scvaddSubview:imgV];
}
[self.view addSubview:scv];
}
-(void)scrollViewDidScroll:(UIScrollView*)scrollView
{
page.currentPage = scv.contentOffset.x/self.view.frame.size.width;
NSLog(@"%lf",scv.contentOffset.x);
}
-(void)change
{
k = scv.contentOffset.x/self.view.frame.size.width;
k++;
scv.contentOffset = CGPointMake(k *self.view.frame.size.width, 0);
if(k>=3)
{
[timerinvalidate];
MainViewController * MainVc = [[MainViewController alloc]init];
//跳转下一个界面
[self presentViewController:MainVc animated:YES completion:nil];
}
}
@end
//主页
#import "OneViewController.h"
#import "DemoCollectionViewCell.h"
@interface OneViewController ()
{
//图片数组
NSArray*arr,*arr1,*arr2;
//表格
UITableView *tbv;
//创建滚动视图
UIScrollView*scrollV;
//滚动视图 图片框
UIImageView *imgV;
//分页
UIPageControl *page;
//创建网格
UICollectionView *collV;
UILabel*lab,*lab1,*lab2,*lab3,*lab4,*lab5;
UIView*myView,*myView1,*myView2;
}
@end
@implementationOneViewController
- (void)viewDidLoad
{
[super viewDidLoad];
//标题
UIImageView*imgTou = [[UIImageViewalloc]initWithFrame:CGRectMake(0,0,60,30)];
imgTou.image= [UIImageimageNamed:@"标题"];
self.navigationItem.titleView = imgTou;
//我的按钮
self.navigationItem.rightBarButtonItem=[[UIBarButtonItemalloc]initWithImage:[UIImageimageNamed:@"我的按钮"] style:UIBarButtonSystemItemDonetarget:selfaction:@selector(rightClick)];
//导航窗口颜色
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
//界面背景颜色
self.view.backgroundColor = [UIColor whiteColor];
//初始化表格
tbv = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
tbv.delegate=self;
tbv.dataSource = self;
[self.view addSubview:tbv];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
return 4;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
staticNSString*str =@"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
if(cell ==nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];
}
switch(indexPath.row)
{
case0:
{
tbv.rowHeight=150;
arr = @[@"10",@"11",@"12",@"13"];
// 创建滚动试图
scrollV= [[UIScrollViewalloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width,150)];
scrollV.backgroundColor= [UIColorgreenColor];
// 设置滚动的范围
scrollV.contentSize = CGSizeMake(self.view.frame.size.width * 4, 150);
// 设置分页
scrollV.pagingEnabled=YES;
// 设置是否滚动
scrollV.scrollEnabled=YES;
// 隐藏水平滚动条
scrollV.showsHorizontalScrollIndicator = NO;
// 取消弹簧效果
scrollV.bounces=NO;
// 设置代理
scrollV.delegate=self;
// 创建图片框
for(inti=0; i<4; i++) {
imgV= [[UIImageViewalloc]initWithFrame:CGRectMake(self.view.frame.size.width* i,0,self.view.frame.size.width,150)];
imgV.image= [UIImageimageNamed:arr[i]];
[scrollVaddSubview:imgV];
}
// 设置位置
page= [[UIPageControlalloc]initWithFrame:CGRectMake((self.view.frame.size.width-100)/2-50,130,100,20)];
// 设置页数
page.numberOfPages=4;
// 默认点的原色
page.pageIndicatorTintColor = [UIColor grayColor];
// 选中页的点的颜色
page.currentPageIndicatorTintColor = [UIColor blueColor];
// 添加到cell上
[cell.contentViewaddSubview:scrollV];
[cell.contentViewaddSubview:page];
// [self.view addSubview:page];
}
break;
case1:
{
tbv.rowHeight=240;
//图片数组
arr1 = @[@"",@"",@"",@"",@"",@"",@"",@""];
//文字数组
arr2 = @[@"账户",@"转账",@"信用卡还款",@"借钱",@"缴费",@"招乎",@"热门活动",@"超级网银"];
// 设置流水布局
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
// 设置单元格大小
layout.itemSize=CGSizeMake(90,90);
// 设置滚动范围(上下)
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
// 设置最小的行间距
layout.minimumLineSpacing=30;
// 设置分区的间距(上左下右)
layout.sectionInset=UIEdgeInsetsMake(5,5,5,5);
// 创建网格
collV = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 240) collectionViewLayout:layout];
//网格的背景色
collV.backgroundColor= [UIColorlightGrayColor];
// 注册cell
[collV registerClass:[DemoCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
// 设置代理和数据源
collV.delegate=self;
collV.dataSource=self;
[cell.contentViewaddSubview:collV];
}
break;
case2:
{
tbv.rowHeight=50;
UIImageView*xlbV = [[UIImageViewalloc]initWithFrame:CGRectMake(10,10,100,30)];
xlbV.image= [UIImageimageNamed:@"xlb"];
[cell.contentViewaddSubview:xlbV];
lab5= [[UILabelalloc]initWithFrame:CGRectMake(115,10,self.view.frame.size.width-115,30)];
lab5.text = @" 为什么苦口婆心劝你:不要提前还房贷!";
lab5.font= [UIFontsystemFontOfSize:15];
[cell.contentViewaddSubview:lab5];
}
break;
case3:
{
tbv.rowHeight=150;
lab= [[UILabelalloc]initWithFrame:CGRectMake(20,0,100,50)];
// lab.backgroundColor = [UIColor greenColor];
lab.text=@"为您推荐";
lab.font= [UIFontsystemFontOfSize:20];
[cell.contentViewaddSubview:lab];
lab1= [[UILabelalloc]initWithFrame:CGRectMake(360,0,100,50)];
// lab1.backgroundColor = [UIColor greenColor];
lab1.text=@"更多";
lab1.textColor= [UIColorgrayColor];
lab1.font= [UIFontsystemFontOfSize:15];
[cell.contentViewaddSubview:lab1];
myView= [[UIViewalloc]initWithFrame:CGRectMake(0,50,self.view.frame.size.width/3-4,100)];
myView.backgroundColor= [UIColorcolorWithRed:175/255.0green:148/255.0blue:111/255.0alpha:1.0];
lab2= [[UILabelalloc]initWithFrame:CGRectMake(10,0,100,33)];
lab2.text=@"短期理财";
lab2.textAlignment = NSTextAlignmentCenter;
lab2.textColor= [UIColorwhiteColor];
[myViewaddSubview:lab2];
lab3= [[UILabelalloc]initWithFrame:CGRectMake(10,33,100,33)];
lab3.text=@"4.75%";
lab3.textAlignment = NSTextAlignmentCenter;
lab3.textColor= [UIColorwhiteColor];
[myViewaddSubview:lab3];
lab4= [[UILabelalloc]initWithFrame:CGRectMake(0,66,130,33)];
lab4.text=@"业绩比较基准";
lab4.font= [UIFontsystemFontOfSize:10];
lab4.textAlignment = NSTextAlignmentCenter;
lab4.textColor= [UIColorwhiteColor];
[myViewaddSubview:lab4];
myView1= [[UIViewalloc]initWithFrame:CGRectMake(self.view.frame.size.width/3,50,self.view.frame.size.width/3-4,100)];
myView1.backgroundColor= [UIColorcolorWithRed:175/255.0green:148/255.0blue:111/255.0alpha:1.0];
UIImageView*image = [[UIImageViewalloc]initWithFrame:CGRectMake(0,3,133,100)];
image.image= [UIImageimageNamed:@"16"];
[myView1addSubview:image];
myView2= [[UIViewalloc]initWithFrame:CGRectMake((self.view.frame.size.width/3)*2+3,50,self.view.frame.size.width/3-4,100)];
myView2.backgroundColor= [UIColorcolorWithRed:175/255.0green:148/255.0blue:111/255.0alpha:1.0];
UIImageView*image1 = [[UIImageViewalloc]initWithFrame:CGRectMake(0,0,150,100)];
image1.image= [UIImageimageNamed:@"17"];
[myView2addSubview:image1];
[cell.contentViewaddSubview:myView];
[cell.contentViewaddSubview:myView1];
[cell.contentViewaddSubview:myView2];
}
default:
break;
}
returncell;
}
// 当试图滚动的时候,调用
-(void)scrollViewDidScroll:(UIScrollView*)scrollView{
page.currentPage = scrollV.contentOffset.x/self.view.frame.size.width;
}
#pragma mark- 数据源方法
// 数据源方法
// 设置分区
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView
{
return 1;
}
// 设置单元格个数
-(NSInteger)collectionView:(UICollectionView*)collectionView numberOfItemsInSection:(NSInteger)section
{
return 8;
}
// 设置单元格内容
-(UICollectionViewCell*)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath:(NSIndexPath*)indexPath{
// 通过可重用标识符查找cell
DemoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
//网格cell颜色
cell.backgroundColor= [UIColorwhiteColor];
cell.img.image= [UIImageimageNamed:@"18"];
cell.label.text=arr2[indexPath.row];
cell.label.textAlignment = NSTextAlignmentCenter;
returncell;
}
@end