iOS--创建uiscrollview

//创建uiscrollview
    self.PageHeight = self.view.bounds.size.height;
    self.PageWidth = self.view.bounds.size.width;
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.PageWidth, self.PageHeight)];

self.scrollView.backgroundColor = [UIColor colorWithRed:61/255.0 green:61/255.0 blue:61/255.0 alpha:1];

[self.view addSubview:self.scrollView];
    self.scrollView.contentSize = CGSizeMake(self.PageWidth*self.FirstLayList.count,self.PageHeight);
    self.scrollView.contentOffset = CGPointMake(0, 0);
    self.scrollView.pagingEnabled = YES;
    
    //加载服务
    self.scrollView.delegate = self;


//完成拖拽
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    NSLog(@"完成拖拽");
    NSInteger juli = scrollView.contentSize.width-_PageWidth-1;
    if (scrollView.contentOffset.x >juli) {
        OldListViewController *oldlist = [self.storyboard instantiateViewControllerWithIdentifier:@"oldlist"];
        [self.navigationController pushViewController:oldlist animated:YES];
    }
}

 

posted on 2017-01-09 17:10  麦芽呀~  阅读(226)  评论(0编辑  收藏  举报