zoukankan      html  css  js  c++  java
  • UI第九节——UIProgressView

    - (void)viewDidLoad {
        [super viewDidLoad];
        
        // 实例化 UIProgressView,高度是固定的
        UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(40, 100, 295, 30)];
       
    #if 1
        // 主题颜色
        progressView.progressTintColor = [UIColor redColor];
        progressView.trackTintColor = [UIColor greenColor];
    #endif
        
    #if 0   // 这个有BUG,不显示
        // 图片
        progressView.progressImage = [UIImage imageNamed:@"slider_track_min"];
        progressView.trackImage = [UIImage imageNamed:@"slider_track_max"];
    #endif
        
        // 把progressView加到self.view上
        [self.view addSubview:progressView];
        
        // 启动一个定时器
        [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerRunning:) userInfo:@{@"progressView": progressView} repeats:YES];
    }

    // 定时会调用一次这个函数
    - (void)timerRunning:(NSTimer *)timer
    {
        UIProgressView *progressView = [timer.userInfo objectForKey:@"progressView"];
        
        // 设置进度
        progressView.progress += 0.1;
        
        NSLog(@"%f", progressView.progress);
        
        // 当进度条完全走完的时候,让定时器停掉
        if (progressView.progress >= 1.0) {
            
            // 销毁定时器
            [timer invalidate];
        }
    }

    如果对你有帮助,请关注我哦!

  • 相关阅读:
    Autodesk vasari Design better buildings
    NOOK2刷机成功
    使用DirectPlay进行网络互联(2)
    程序员的灯下黑:不要忘记你的目标
    【ZT】中西医的区别
    D3D中公告板的使用示例
    使用DirectPlay进行网络互联(1)
    使用DirectPlay进行网络互联(4)
    计算几何常用算法概览
    DirectX9.0教程之ID3DXSprite篇[转载]
  • 原文地址:https://www.cnblogs.com/laolitou-ping/p/6244161.html
Copyright © 2011-2022 走看看