• UI<03>


    //声明 UIScrollView-》#27932A  #952775 #602AAB
    @property (nonatomic,strong) UIScrollView *scrollview;
    //声明 UIImageView
    @property (nonatomic,strong) UIImageView *imageview;
     
        //初始化 UIScrollView
        self.scrollview = [[UIScrollView alloc] init];
        //设置 frame
        self.scrollview.frame = self.imageview.bounds;
        //设置背景色
        self.scrollview.backgroundColor = [UIColor blueColor];
        //设置滚动范围
        self.scrollview.contentSize = CGSizeMake(self.imageview.image.size.width, self.imageview.image.size.height);
        //设置滚动的位置
        self.scrollview.contentOffset = CGPointMake(0,0);
        //设置内边距
        self.scrollview.contentInset = UIEdgeInsetsMake(0,0, 80, 100)
        ;
        //设置是否有弹簧效果
        self.scrollview.bounces = YES;
        //默认no,控制垂直方向遇到边框是否反弹(但bounces为NO时,它为yes,也不反弹)
        self.scrollview.alwaysBounceVertical = YES;
        //默认no,控制水平方向遇到边框是否反弹(但bounces为NO时,它为yes,也不反弹)
        self.scrollview.alwaysBounceHorizontal = YES;
        //是否允许滚动到顶部
        self.scrollview.scrollsToTop = YES;
        //设置是否分页
        self.scrollview.pagingEnabled = NO;
        //设置是否允许拖动
        self.scrollview.scrollEnabled = YES;
        //设置是否显示水平滚动条
        self.scrollview.showsHorizontalScrollIndicator = YES;
        //设置是否显示垂直滚动条
        self.scrollview.showsVerticalScrollIndicator = YES;
        //设置滚动条的位置
        self.scrollview.scrollIndicatorInsets = UIEdgeInsetsMake(0,0,0,0);
        //设置滚动条的样式
        self.scrollview.indicatorStyle = UIScrollViewIndicatorStyleDefault;
       
        //设置 代理
        self.scrollview.delegate = self;
       
        //设置最大/最小缩放比
        self.scrollview.maximumZoomScale = 1.0;
        self.scrollview.minimumZoomScale = 3.5;
       
       
        [self.view addSubview:self.scrollview];
        [self.scrollview addSubview:self.imageview];
     
     
     
        CGFloat Y = self.scrollview.contentOffset.y + 5;
        CGFloat X = self.scrollview.contentOffset.x + 5;
        //设置滚动的位置
        [self.scrollview setContentOffset:CGPointMake(X, Y) animated:YES];
       
     
       
    //遵守代议 :UIScrollViewDelegate
    #pragma mark - Delegate

    //正在滚动
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
       
        NSLog(@"正在滚动...");
       
    }
    //即将开始滚动。
    -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
       
         NSLog(@"即将开始滚动...");
       
    }
    //完成滚动(松手后调用)
    -(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
       
        NSLog(@"完成滚动...");
       
    }
    //开始减速滚动(完成滚动 调用)
    -(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
       
        NSLog(@"开始减速滚动...");
       
    }
    //结束减速滚动 (滚动结束调用)
    -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
       
        NSLog(@"结束减速滚动...");
       
    }
    //滚动到顶部
    -(BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView{
       
         NSLog(@"滚动到顶部...");
        return YES;
    }
    //滚动到顶部调用(scrollsToTop 设置为YES时点击状态栏调用)
    -(void)scrollViewDidScrollToTop:(UIScrollView *)scrollView{
       
         NSLog(@"滚动到顶部调用...");
    }
    //设置缩放的对象
    -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
       
       
        return self.imageview;
       
    }
    //即将开始缩放
    -(void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view{
       
          NSLog(@"即将开始缩放...");
       
    }
    //正在缩放
    -(void)scrollViewDidZoom:(UIScrollView *)scrollView{
       
        NSLog(@"正在缩放...");
       
    }
  • 相关阅读:
    springmvc
    POJ 3683 Priest John's Busiest Day
    POJ 3678 Katu Puzzle
    HDU 1815 Building roads
    CDOJ UESTC 1220 The Battle of Guandu
    HDU 3715 Go Deeper
    HDU 3622 Bomb Game
    POJ 3207 Ikki's Story IV
    POJ 3648 Wedding
    HDU 1814 Peaceful Commission
  • 原文地址:https://www.cnblogs.com/iQingYang/p/6677499.html
Copyright © 2020-2023  润新知