iPhone 上实现页面循环滚动
2010-03-10 16:10:00 来源:WEB开发网[sview addSubview:pView];
[pView release];
rc.origin.x += perWidth;
pView.font = [UIFont systemFontOfSize:40];
pView.tag = 0x12345691;
}
rcSize.width = nViewCount* rcSize.width;
sview.contentSize = rcSize;
sview.pagingEnabled = YES;
sview.bounces = NO;
CGPoint contextOff = {300,0};
[sview setContentOffset:contextOff animated:NO];
}
-(void)setUpViews:(ExScrollView*)sview
{
CGRect dddd = [sview frame];
CGSize rcSize = dddd.size;
int nViewCount = 3;
int perWidth = rcSize.width;
CGRect rc = CGRectMake(0, 0, perWidth, rcSize.height);
UIColor* color[6];
color[0] = [UIColor brownColor];
color[1] = [UIColor purpleColor];
color[2] = [UIColor orangeColor];
color[3] = [UIColor magentaColor];
color[4] = [UIColor yellowColor];
color[5] = [UIColor cyanColor];
int i=0;
for(;i
{
UITextView* pView = [[UITextView alloc] initWithFrame:rc];
UIColor* pColor = color[i%5];
pView.backgroundColor = pColor;
pView.text = [NSString stringWithFormat:@"%view:%d",i+1];
pView.editable = NO;
[sview addSubview:pView];
[pView release];
rc.origin.x += perWidth;
pView.font = [UIFont systemFontOfSize:40];
pView.tag = 0x12345691;
}
rcSize.width = nViewCount* rcSize.width;
sview.contentSize = rcSize;
sview.pagingEnabled = YES;
sview.bounces = NO;
CGPoint contextOff = {300,0};
[sview setContentOffset:contextOff animated:NO];
}
UIScrollView的代理接口实现:
view plaincopy to clipboardprint?
更多精彩
赞助商链接