zoukankan      html  css  js  c++  java
  • UI基础 ScrollView轮播图

    root m

    #import "RootViewController.h"
    
    @interface RootViewController ()
    
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        UIScrollView* sv=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 375, 667)];
        
        sv.backgroundColor=[UIColor yellowColor];
        [self.view addSubview:sv];
        
        //设置大小 多大才能装下四张图片
        sv.contentSize=CGSizeMake(375*4, 667);
        //把图片装进去
        for(int i=1; i<=4; i++){
            NSString* name =[NSString stringWithFormat:@"%d.jpg",i];
            UIImage *image =[UIImage imageNamed:name];
            UIImageView* imageV=[[UIImageView alloc] initWithFrame:CGRectMake(375*(i-1), 0, 375, 667)];
            
            imageV.image=image;
            [sv addSubview:imageV];
            
            
            //分页显示
            sv.pagingEnabled=YES;
            //是否允许反弹
            sv.bounces=NO;
            // 修改滚动条样式
            sv.indicatorStyle=UIScrollViewIndicatorStyleWhite;
            //隐藏滚动条
            sv.showsHorizontalScrollIndicator=NO;
            sv.showsVerticalScrollIndicator=NO;
            //滑动到指定位置
            sv.contentOffset=CGPointMake(375, 0);
            
            
            
        }
        
        
    }
    
    
    
    @end
  • 相关阅读:
    微信支付退款部分代码
    Raspberry PI 点亮LED
    Raspberry PI 摄像头
    RaspberryPI 3B系统烧录
    MySQL基础使用
    MySQL数据库管理系统概述
    Eclipse创建JAVA项目
    Brup Suite拦截https请求
    Github 第一个仓库
    python os模块主要函数
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13401279.html
Copyright © 2011-2022 走看看