• 利用定时器展示动态文字


     1 #import "ViewController.h"
     2 
     3 static NSInteger count = 0;
     4 
     5 @interface ViewController ()
     6 
     7 @property (weak, nonatomic) IBOutlet UILabel *label;
     8 
     9 @property (nonatomic, strong)NSArray *array;
    10 /** 添加定时器 */
    11 @property (nonatomic, strong) NSTimer *time;
    12 
    13 @end
    14 
    15 @implementation ViewController
    16 
    17 - (NSArray *)array
    18 {
    19     if(!_array)
    20     {
    21         _array = [NSArray arrayWithObjects:@"1...",@"2....",@"3.....",@"4......", nil];
    22     }
    23     return _array;
    24 }
    25 
    26 - (void)viewDidLoad {
    27     [super viewDidLoad];
    28     
    29     self.time = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(runLabel) userInfo:nil repeats:YES];
    30     [self.time fire]; // 立即触发定时器
    31 //    [time setFireDate:[NSDate distantPast]]; // 开启定时器
    32 //    [time setFireDate:[NSDate distantFuture]]; // 暂停定时器
    33 }
    34 
    35 - (void)runLabel
    36 {
    37     self.label.text = self.array[count++ % self.array.count];
    38 }
    39 
    40 /** 移除定时器 */
    41 - (void)removeTimer
    42 { // 定时器一旦被停止,不会重新开始,要被移除。
    43     [self.time invalidate];
    44     self.time = nil;
    45 }
    46 - (void)didReceiveMemoryWarning {
    47     [super didReceiveMemoryWarning];
    48     // Dispose of any resources that can be recreated.
    49 }
    50 
    51 @end



  • 相关阅读:
    Hbase 笔记(4) 客户端API高级性能
    Hbase 笔记(3) 客户端API基础
    Hbase 笔记(2) 安装
    HBase 笔记(1) 简介
    Global 和 Local 索引。
    Phoenix Tips (14) mutable 和 immutable 表区别
    Phoenix Tips (13) 统计收集
    Phoenix Tips (12) 跟踪 Tracing
    Phoenix Tips (11) Skip Scan
    Phoenix Tips (10) 分页查询
  • 原文地址:https://www.cnblogs.com/shen5214444887/p/4877529.html
Copyright © 2020-2023  润新知