直播中的網速返回

- (NSString *)netStatChangeBytes:(long )bytes {
    
    if (bytes <= 0) {

        return [NSString stringWithFormat:@"網速:0B..."];
    }
    
    if (bytes < 1024) {         //B
        return [NSString stringWithFormat:@"網速:%ldB",bytes];
    }else if (bytes >= 1024 && bytes < 1024 *1024){//KB
        return [NSString stringWithFormat:@"網速:%.1fkb",(double)bytes/1024];
    }else if (bytes >= 1024 * 1024 && bytes < 1024 * 1024 * 1024) { //MB
        return [NSString stringWithFormat:@"網速:%.1fMB",(double)bytes/(1024 * 1024)];
    }else {  //GB
        return [NSString stringWithFormat:@"網速:%.1fGB",(double)bytes/(1024 * 1024 * 1024)];
    }
    
}


發佈了40 篇原創文章 · 獲贊 11 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章