zoukankan      html  css  js  c++  java
  • UIScrollView 知识

    - (void)viewDidLoad {

        [super viewDidLoad];

        

    //    [self firstUIScrollView];

        [self secondUIScrollView];

    }

    // 给定的frame 正常的显示 

    - (void)firstUIScrollView{

        

        UIScrollView *firstScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 100,kScreenWidth , 300)];

        

    //One

        firstScroll.contentOffset = CGPointMake(kScreenWidth , 100);

        firstScroll.contentSize = CGSizeMake(kScreenWidth * 3, 300);// 内容的大小

        //firstScroll.contentInset = UIEdgeInsetsMake(10, 20, 30, 40);

        // 滑动锁定  左右滑动的同时不可以上下滑动  反之也是

        firstScroll.directionalLockEnabled = YES;

        //bounces 是否有弹簧效果

        firstScroll.bounces = YES;

        firstScroll.alwaysBounceVertical = YES;

        firstScroll.pagingEnabled = YES;// 分页效果

        // yes--> 可以滑动   no---> 不可以滑动

        firstScroll.scrollEnabled = YES;

        // 显示水平滑动条  no ---> 不显示   yes  ---> 显示

        firstScroll.showsHorizontalScrollIndicator = YES;

        // 显示垂直滑动条

        firstScroll.showsVerticalScrollIndicator = YES;

        // 指示条的位置

        firstScroll.scrollIndicatorInsets = UIEdgeInsetsMake(10, 20, 30, 40);

        // 它的值域是(0.01.0

        firstScroll.decelerationRate = 1.0;

        

    //Two

        // tracking  touch后还没有拖动的时候值是YES,否则NO

        if (firstScroll.tracking) {

            

            NSLog(@"tracking = yes");

        }

        else{

            NSLog(@"tracking = no");

        }

        

        

        firstScroll.minimumZoomScale = 0.1;

        firstScroll.maximumZoomScale = 1.0;

        

        firstScroll.backgroundColor = [UIColor cyanColor];

        [self.view addSubview:firstScroll];

        

        NSArray *array = @[@"two",@"one",@"two"];

        for (int i = 0; i<3; i++) {

            UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(i*kScreenWidth, 0, kScreenWidth,300)];

            imageV.image = [UIImage imageNamed:[array objectAtIndex:i]];

            [firstScroll addSubview:imageV];

        }

    }

     

     // 使用自动约束

    - (void)secondUIScrollView{

        

        

        //initWithFrame:CGRectMake(0, 100,kScreenWidth , 300)

        UIScrollView *second = [[UIScrollView alloc] init];

        second.translatesAutoresizingMaskIntoConstraints = NO;

        

        second.contentOffset = CGPointMake(kScreenWidth, 100);

        second.contentSize = CGSizeMake(kScreenWidth * 3, 400);

        second.pagingEnabled = YES;

        second.backgroundColor = [UIColor redColor];

        [self.view addSubview:second];

        

        [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[second]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(second)]];

        

        [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-100-[second(400)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(second)]];

        // 图片名字放在数组中

        NSArray *array = @[@"two",@"one",@"two"];

        for (int i = 0; i<3; i++) {

            UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(i*kScreenWidth, 0, kScreenWidth,400)];

            imageV.image = [UIImage imageNamed:[array objectAtIndex:i]];

            [second addSubview:imageV];

        }

     

        

        

    }

     

  • 相关阅读:
    Maven中使用描述文件切换环境配置
    整合MyBatis到Spring中实现Dao层自动装配
    使用MyBatis搭建项目时报 java.io.IOException: Could not find resource
    数据库CPU占用高排查
    JS 根据时区获取时间
    国外服务器 winserver2012 安装IIS后,安装urlrewrite模块总是自动停止应用程序池
    sql中char(9) char(10) char(13)
    通过 Microsoft.Ace.OLEDB 接口导入 EXCEL 到SQLSERVER
    SDL 当前连接查询脚本
    C# System.Drawing.Graphics 画图后,如何保存一个低质量的图片,一个占用空间较小的图片
  • 原文地址:https://www.cnblogs.com/tom2015010203/p/5462831.html
Copyright © 2011-2022 走看看