_scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 20, 320, 460)];
_scroll.contentSize=CGSizeMake(320*4, 460);
_scroll.pagingEnabled=YES;
_scroll.bounces=NO;//不想让用户的滚动范围能够超出可见内容
for(int i=1;i<5;i++)
{
UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(320*(i-1), 0, 320, 460)];
NSString *path=[[NSBundle mainBundle]pathForResource:[NSString stringWithFormat:@"%d",i] ofType:@"png"];
UIImage *img=[UIImage imageWithContentsOfFile:path];
[imageView setImage:img];
[_scroll addSubview:imageView];
[imageView release];
}
UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
btn.frame=CGRectMake(320*3, 0, 320, 460);
[btn addTarget:self action:@selector(backhome) forControlEvents:UIControlEventTouchUpInside];
[_scroll addSubview:btn];
[self.view addSubview:_scroll];
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。