iOS

UIScrollView

2019-06-04  本文已影响0人  习惯了_就好
![1559617276358.jpg](https://img.haomeiwen.com/i2991872/6066b8eb9a175ed0.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


 //scrollview能滚动内容的尺寸,必须设置,ScrollView才能滚动
//    self.myScrollView.contentSize = self.myImageView.frame.size;
    self.myScrollView.contentSize = CGSizeMake(1000, 1000);
    
    //ScrollView四周额外增加的范围
    self.myScrollView.contentInset = UIEdgeInsetsMake(10, 20, 30, 40);
    
    //ScrollView滑动的偏移量
    self.myScrollView.contentOffset = CGPointMake(0, -100);
    // 隐藏水平滚动条
    self.scrollView.showsHorizontalScrollIndicator = NO;
    
    // 分页
    self.scrollView.pagingEnabled = YES;

//    是否能滚动
    self.myScrollView.scrollEnabled = false;
//    是否需要弹簧效果
    self.myScrollView.bounces = NO;

//代理UIScrollViewDelegate

//关联代理
    self.myScrollView.delegate = self;
// 设置最大和最小的缩放比例
    self.myScrollView.maximumZoomScale = 2.0;
    self.myScrollView.minimumZoomScale = 0.2;

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    NSLog(@"开始拖拽");
}

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView {
    NSLog(@"停止拖拽");
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"正在滚动");
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
    NSLog(@"返回要缩放对象");
    return self.myImageView;
}


-(void)scrollViewDidZoom:(UIScrollView *)scrollView{
    NSLog(@"正在缩放");
}

上一篇下一篇

猜你喜欢

热点阅读