雜七雜八

NS_REQUIRES_NIL_TERMINATION

<code>titles:(NSString *)firstTitle, ... NS_REQUIRES_NIL_TERMINATION</code>

列表foot和header不滑動(dòng)

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat sectionHeaderHeight = 40;
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    }else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }
}

剪裁圖片尺寸

- (UIImage *)scaleFromImage:(UIImage *)image toSize:(CGSize)size
{
    UIGraphicsBeginImageContext(size);
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
    
}

時(shí)間戳

//時(shí)間戳 轉(zhuǎn)成 時(shí)間
- (NSString *)dateTo:(NSString *)str
{
    NSTimeInterval time=[str integerValue];
    
    NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    
    //設(shè)定時(shí)間格式,這里可以設(shè)置成自己需要的格式
    
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    
    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
    return currentDateStr;
}

//時(shí)間 轉(zhuǎn)成 時(shí)間戳
- (NSString *)dateFromString:(NSString *)dateString{
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    
    [dateFormatter setDateFormat: @"yyyy-MM-dd"];
    
    
    
    
    NSDate *destDate= [dateFormatter dateFromString:dateString];
    NSString * timeSp = [NSString stringWithFormat:@"%ld",(long)[destDate timeIntervalSince1970]];
    return timeSp;
    
}

獲取視頻封面圖片

- (UIImage *)thumbnailImageForVideo:(NSURL *)videoURL atTime:(NSTimeInterval)time{
    AVURLAsset * asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil];
    NSParameterAssert(asset);
    AVAssetImageGenerator * assetImageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    
    assetImageGenerator.appliesPreferredTrackTransform = YES;
    assetImageGenerator.apertureMode =AVAssetImageGeneratorApertureModeEncodedPixels;
    
    CGImageRef thumnailImageRef = NULL;
    CFTimeInterval thumnailImageTime = time;
    NSError * thumnailImageGenerationError = nil;
    thumnailImageRef = [assetImageGenerator copyCGImageAtTime:CMTimeMake(thumnailImageTime, 60) actualTime:NULL error:&thumnailImageGenerationError];
    if (!thumnailImageRef) {
        NSLog(@"%@",thumnailImageGenerationError);
    }
    UIImage * thumbnailImage = thumnailImageRef?[[UIImage alloc] initWithCGImage:thumnailImageRef]:nil;
    return thumbnailImage;
}

書名

    NSString *dbPath = [NSHomeDirectory() stringByAppendingString:@"/Documents"];
    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager]enumeratorAtPath:dbPath];
    for (NSString *fileName in enumerator)
    {
        NSLog(@"書名:   %@",fileName);
    }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容