ios 显示当前时间

        一些应用中,为了和主题风格保持一致,需要隐藏了ipad或者iphone中的statusBar       ([UIApplication sharedApplication].statusBarHidden  = YES ; ),而自己写时间条。在时间条中,时间是一秒中刷新一次。


1、主要是用到一下的函数方法:

      

    NSTimer *timer = [NSTimerscheduledTimerWithTimeInterval:1target:self 

    selector:@selector(updateDate)userInfo:nilrepeats:YES];

    [timer fire];


    其中1代表的是刷新间隔的时间为1秒。

    updateDate方法是具体更改显示时间。

2、updateDate方法涉及到的内容:

    

     - (void)updateDate{

       

         [selfgetCurrentTime:@"YYYY":5:yyyy];

     

         [selfgetCurrentTime:@"MM" :60:MM];

    

         [selfgetCurrentTime:@"dd" :95:dd];

    

         [selfgetCurrentTime:@"hh" :140:hh];

    

         [selfgetCurrentTime:@"mm" :165:mm];

    

   [selfgetCurrentTime:@"ss" :190:ss];

 

}


  其中:getCurrentTime方法是具体得到当前的各个时间的显示格式,显示label的横坐标,和显示的

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值