很早以前都做过这个效果,之前一直都没有写过东西,今天看到就写了一个......
-(UIScrollView *)scrollView
{
if (!_scrollView) {
_scrollView=[[UIScrollView alloc]init];
_scrollView.frame=CGRectMake(50, 200, YHScreenWith-100, 300);
_scrollView.delegate=self;
// _scrollView.showsVerticalScrollIndicator=NO;
_scrollView.backgroundColor=[UIColor clearColor];
_scrollView.clipsToBounds = NO;
self.view.clipsToBounds = YES;
NSArray *imageArray = @[@"1",@"2",@"3",@"4",@"5",@"6"]; //图片内容
//
for (NSInteger i = 0; I < imageArray.count; i ++) {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake((YHScreenWith -100) *i, 0, YHScreenWith -100, 300)];
view.backgroundColor = [UIColor clearColor];
[self.scrollView addSubview:view];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, view.width -20, 300)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageArray[i]]];
[view addSubview:imageView];
}
_scrollView.contentSize = CGSizeMake((YHScreenWith -100) *6, 300);
_scrollView.pagingEnabled = YES;
_scrollView.contentOffset = CGPointMake((YHScreenWith -100) *1, 0);
[self.view addSubview:self.scrollView];
}
return _scrollView;
}
效果图
网友评论