常用NString格式化

   //  点赞数据格式话,保留小数点后面1位小数

    NSString* result = [NSString stringWithFormat:@"%.1f万",number/10000];

    NSLog(@"%@",result);


    

  // 时间格式话

    NSInteger videotime=300// 秒

    NSInteger minute = videotime / 60;

    NSInteger second = videotime % 60;

      //  %04zd - 占据4位,空出来的位用0来填补

    NSString* time=  [NSString stringWithFormat:@"%02zd:%02zd", minute, second];

    

    NSLog(@"%@",time);


  //百分比

self.cicle_progress.progressLabel.text = [NSString stringWithFormat:@"%.0f%%", currentFloat * 100];


猜你喜欢

转载自blog.csdn.net/dreams_deng/article/details/80622300