-(void)setOffset:(CGFloat)offset{_offset=offset;// Do something with offsetX}-(void)scrollViewDidScroll:(UIScrollView*)scrollView{CGFloatwidth=scrollView.bounds.size.width;CGFloatoffset=self.offset;NSIntegerchildCount=self.childControllers.count;// 将当前滑动显示的view 的坐标 => self.view 的坐标for(UIViewController*vcinself.childControllers){CGPointp=[vc.viewconvertPoint:CGPointMake(0,0)toView:self.view];if(p.x>0&&p.x<width){NSIntegerindex=[self.childControllersindexOfObject:vc];offset=index*width-p.x;}}if(offset>=(childCount-1)*width){CGPointp=[self.childControllers.lastObject.viewconvertPoint:CGPointMake(0,0)toView:self.view];offset=(childCount-1)*width-p.x;}self.offset=offset;}-(void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView{CGFloatwidth=scrollView.bounds.size.width;NSIntegerindex=round(self.offset/width);if(index<0){index=self.childControllers.count-1;}self.offset=index*width;}