【iOS学习】 视频添加动效水印步骤简介
yuyutoo 2025-01-12 19:56 5 浏览 0 评论
简概:
本次文章主要介绍给视频添加动效水印的几种方式,以及实现代码。
使用AVFoundation + CoreAnimation 合成方式
基于Lottie 核心也是 CoreAnimation ,这里我们也可以使用AVFoundation + Lottie 合成方式
我们同样可以使用序列帧资源或者gif资源 来编写一段keyFrameAnination,这里我们就介绍一段 AVFoundation + Gif 合成方式
使用 GPUImageUIElement 将序列帧资源合并在目标资源上
使用 GPUImage 将水印视频合并在目标资源上
如果你有问题,或者对下述文字有任何意见与建议,可以在文章最后留言
视频处理后效果 GIF
原视频.gif
CoreAnimation.gif
Lottie.gif
GIF.gif
GPUImageType1.gif
GPUImageType2.gif
1.使用AVFoundation + CoreAnimation 合成方式
#pragma mark CorAnimation+ (void)addWaterMarkTypeWithCorAnimationAndInputVideoURL:(NSURL*)InputURL WithCompletionHandler:(void(^)(NSURL* outPutURL, intcode))handler{ NSDictionary *opts = [NSDictionary dictionaryWithObject:@(YES) forKey:AVURLAssetPreferPreciseDurationAndTimingKey]; AVAsset *videoAsset = [AVURLAsset URLAssetWithURL:InputURL options:opts]; AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init]; AVMutableCompositionTrack *videoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
preferredTrackID:kCMPersistentTrackID_Invalid]; NSError *errorVideo = [NSError new]; AVAssetTrack *assetVideoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo]firstObject]; CMTime endTime = assetVideoTrack.asset.duration; BOOL bl = [videoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, assetVideoTrack.asset.duration)
ofTrack:assetVideoTrack
atTime:kCMTimeZero error:&errorVideo];
videoTrack.preferredTransform = assetVideoTrack.preferredTransform; NSLog(@"errorVideo:%ld%d",errorVideo.code,bl); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyyMMddHHmmss"; NSString *outPutFileName = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]]; NSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mov",outPutFileName]]; NSURL* outPutVideoUrl = [NSURL fileURLWithPath:myPathDocs];
CGSize videoSize = [videoTrack naturalSize];
UIFont *font = [UIFont systemFontOfSize:60.0]; CATextLayer *aLayer = [[CATextLayer alloc] init];
[aLayer setFontSize:60];
[aLayer setString:@"H"];
[aLayer setAlignmentMode:kCAAlignmentCenter];
[aLayer setForegroundColor:[[UIColor greenColor] CGColor]];
[aLayer setBackgroundColor:[UIColor clearColor].CGColor]; CGSize textSize = [@"H"sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName, nil]];
[aLayer setFrame:CGRectMake(240, 470, textSize.width, textSize.height)];
aLayer.anchorPoint = CGPointMake(0.5, 1.0);
CATextLayer *bLayer = [[CATextLayer alloc] init];
[bLayer setFontSize:60];
[bLayer setString:@"E"];
[bLayer setAlignmentMode:kCAAlignmentCenter];
[bLayer setForegroundColor:[[UIColor greenColor] CGColor]];
[bLayer setBackgroundColor:[UIColor clearColor].CGColor]; CGSize textSizeb = [@"E"sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName, nil]];
[bLayer setFrame:CGRectMake(240+ textSize.width, 470, textSizeb.width, textSizeb.height)];
bLayer.anchorPoint = CGPointMake(0.5, 1.0);
CATextLayer *cLayer = [[CATextLayer alloc] init];
[cLayer setFontSize:60];
[cLayer setString:@"L"];
[cLayer setAlignmentMode:kCAAlignmentCenter];
[cLayer setForegroundColor:[[UIColor greenColor] CGColor]];
[cLayer setBackgroundColor:[UIColor clearColor].CGColor]; CGSize textSizec = [@"L"sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName, nil]];
[cLayer setFrame:CGRectMake(240+ textSizeb.width + textSize.width, 470, textSizec.width, textSizec.height)];
cLayer.anchorPoint = CGPointMake(0.5, 1.0);
CATextLayer *dLayer = [[CATextLayer alloc] init];
[dLayer setFontSize:60];
[dLayer setString:@"L"];
[dLayer setAlignmentMode:kCAAlignmentCenter];
[dLayer setForegroundColor:[[UIColor greenColor] CGColor]];
[dLayer setBackgroundColor:[UIColor clearColor].CGColor]; CGSize textSized = [@"L"sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName, nil]];
[dLayer setFrame:CGRectMake(240+ textSizec.width+ textSizeb.width + textSize.width, 470, textSized.width, textSized.height)];
dLayer.anchorPoint = CGPointMake(0.5, 1.0);
CATextLayer *eLayer = [[CATextLayer alloc] init];
[eLayer setFontSize:60];
[eLayer setString:@"O"];
[eLayer setAlignmentMode:kCAAlignmentCenter];
[eLayer setForegroundColor:[[UIColor greenColor] CGColor]];
[eLayer setBackgroundColor:[UIColor clearColor].CGColor]; CGSize textSizede = [@"O"sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName, nil]];
[eLayer setFrame:CGRectMake(240+ textSized.width + textSizec.width+ textSizeb.width + textSize.width, 470, textSizede.width, textSizede.height)];
eLayer.anchorPoint = CGPointMake(0.5, 1.0); CABasicAnimation* basicAni = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
basicAni.fromValue = @(0.2f);
basicAni.toValue = @(1.0f);
basicAni.beginTime = AVCoreAnimationBeginTimeAtZero;
basicAni.duration = 2.0f;
basicAni.repeatCount = HUGE_VALF;
basicAni.removedOnCompletion = NO;
basicAni.fillMode = kCAFillModeForwards;
[aLayer addAnimation:basicAni forKey:nil];
[bLayer addAnimation:basicAni forKey:nil];
[cLayer addAnimation:basicAni forKey:nil];
[dLayer addAnimation:basicAni forKey:nil];
[eLayer addAnimation:basicAni forKey:nil];
CALayer *parentLayer = [CALayer layer]; CALayer *videoLayer = [CALayer layer];
parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height);
videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height);
[parentLayer addSublayer:videoLayer];
[parentLayer addSublayer:aLayer];
[parentLayer addSublayer:bLayer];
[parentLayer addSublayer:cLayer];
[parentLayer addSublayer:dLayer];
[parentLayer addSublayer:eLayer]; AVMutableVideoComposition* videoComp = [AVMutableVideoComposition videoComposition];
videoComp.renderSize = videoSize;
parentLayer.geometryFlipped = true;
videoComp.frameDuration = CMTimeMake(1, 30);
videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; AVMutableVideoCompositionInstruction* instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
instruction.timeRange = CMTimeRangeMake(kCMTimeZero, endTime); AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:videoTrack];
instruction.layerInstructions = [NSArray arrayWithObjects:layerInstruction, nil];
videoComp.instructions = [NSArray arrayWithObject: instruction];
AVAssetExportSession* exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition
presetName:AVAssetExportPresetHighestQuality];
exporter.outputURL=outPutVideoUrl;
exporter.outputFileType = AVFileTypeMPEG4;
exporter.shouldOptimizeForNetworkUse = YES;
exporter.videoComposition = videoComp;
[exporter exportAsynchronouslyWithCompletionHandler:^{ dispatch_async(dispatch_get_main_queue(), ^{ //这里是输出视频之后的操作,做你想做的
NSLog(@"输出视频地址:%@ andCode:%@",myPathDocs,exporter.error);
handler(outPutVideoUrl,(int)exporter.error.code);
});
}];
}
2.基于Lottie 核心也是 CoreAnimation ,这里我们也可以使用AVFoundation +Lottie 合成方式
与第一段代码不同的地方
LOTAnimationView* animation = [LOTAnimationView animationNamed:@"青蛙"];
animation.frame = CGRectMake(150, 340, 240, 240);
animation.animationSpeed = 5.0;
animation.loopAnimation = YES;
[animation play];
CALayer *parentLayer = [CALayer layer]; CALayer *videoLayer = [CALayer layer];
parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height);
videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height);
[parentLayer addSublayer:videoLayer];
[parentLayer addSublayer:animation.layer];
3.我们同样可以使用序列帧资源或者gif资源 来编写一段keyFrameAnination,这里我们就介绍一段 AVFoundation + Gif 合成方式
与第一段代码不同的地方是将gif 转成layer 的KEYFrameAnimation
CALayer *gifLayer1 = [[CALayer alloc] init];
gifLayer1.frame = CGRectMake(150, 340, 298, 253); CAKeyframeAnimation *gifLayer1Animation = [WatermarkEngine animationForGifWithURL:[[NSBundle mainBundle] URLForResource:@"雪人完成_1"withExtension:@"gif"]];
gifLayer1Animation.beginTime = AVCoreAnimationBeginTimeAtZero;
gifLayer1Animation.removedOnCompletion = NO;
[gifLayer1 addAnimation:gifLayer1Animation forKey:@"gif"];
CALayer *parentLayer = [CALayer layer]; CALayer *videoLayer = [CALayer layer];
parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height);
videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height);
[parentLayer addSublayer:videoLayer];
[parentLayer addSublayer:gifLayer1];
+ (CAKeyframeAnimation *)animationForGifWithURL:(NSURL *)url {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
NSMutableArray * frames = [NSMutableArray new]; NSMutableArray *delayTimes = [NSMutableArray new];
CGFloat totalTime = 0.0; CGFloat gifWidth; CGFloat gifHeight;
CGImageSourceRef gifSource = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
// get frame count
size_t frameCount = CGImageSourceGetCount(gifSource); for(size_t i = 0; i < frameCount; ++i) { // get each frame
CGImageRef frame = CGImageSourceCreateImageAtIndex(gifSource, i, NULL);
[frames addObject:(__bridge id)frame]; CGImageRelease(frame);
// get gif info with each frame
NSDictionary *dict = (NSDictionary*)CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(gifSource, i, NULL)); NSLog(@"kCGImagePropertyGIFDictionary %@", [dict valueForKey:(NSString*)kCGImagePropertyGIFDictionary]);
// get gif size
gifWidth = [[dict valueForKey:(NSString*)kCGImagePropertyPixelWidth] floatValue];
gifHeight = [[dict valueForKey:(NSString*)kCGImagePropertyPixelHeight] floatValue];
// kCGImagePropertyGIFDictionary中kCGImagePropertyGIFDelayTime,kCGImagePropertyGIFUnclampedDelayTime值是一样的
NSDictionary *gifDict = [dict valueForKey:(NSString*)kCGImagePropertyGIFDictionary];
[delayTimes addObject:[gifDict valueForKey:(NSString*)kCGImagePropertyGIFUnclampedDelayTime]];
totalTime = totalTime + [[gifDict valueForKey:(NSString*)kCGImagePropertyGIFUnclampedDelayTime] floatValue];
// CFRelease((__bridge CFTypeRef)(dict));
// CFRelease((__bridge CFTypeRef)(dict));
} if(gifSource) { CFRelease(gifSource);
}
NSMutableArray *times = [NSMutableArray arrayWithCapacity:3]; CGFloat currentTime = 0; NSInteger count = delayTimes.count; for(inti = 0; i < count; ++i) {
[times addObject:[NSNumber numberWithFloat:(currentTime / totalTime)]];
currentTime += [[delayTimes objectAtIndex:i] floatValue];
}
NSMutableArray *images = [NSMutableArray arrayWithCapacity:3]; for(inti = 0; i < count; ++i) {
[images addObject:[frames objectAtIndex:i]];
}
animation.keyTimes = times;
animation.values = images;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animation.duration = totalTime;
animation.repeatCount = HUGE_VALF;
returnanimation;
}
4.使用 GPUImage 将水印视频合并在目标资源上
#pragma mark GPUImage TWO VIDEO INPUT+ (void)addWaterMarkTypeWithGPUImageAndInputVideoURL:(NSURL*)InputURL AndWaterMarkVideoURL:(NSURL*)InputURL2 WithCompletionHandler:(void(^)(NSURL* outPutURL, intcode))handler{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyyMMddHHmmss"; NSString *outPutFileName = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]]; NSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mov",outPutFileName]]; NSURL* outPutVideoUrl = [NSURL fileURLWithPath:myPathDocs];
GPUImageMovie* movieFile = [[GPUImageMovie alloc] initWithURL:InputURL];
GPUImageMovie* movieFile2 = [[GPUImageMovie alloc] initWithURL:InputURL2];
GPUImageScreenBlendFilter* filter = [[GPUImageScreenBlendFilter alloc] init];
[movieFile addTarget:filter];
[movieFile2 addTarget:filter];
GPUImageMovieWriter* movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:outPutVideoUrl size:CGSizeMake(540, 960) fileType:AVFileTypeQuickTimeMovie outputSettings: @
{ AVVideoCodecKey: AVVideoCodecH264, AVVideoWidthKey: @540, //Set your resolution width here
AVVideoHeightKey: @960, //set your resolution height here
AVVideoCompressionPropertiesKey: @
{ //2000*1000 建议800*1000-5000*1000
//AVVideoAverageBitRateKey: @2500000, // Give your bitrate here for lower size give low values
AVVideoAverageBitRateKey: @5000000, AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel, AVVideoAverageNonDroppableFrameRateKey: @30,
},
}
];
[filter addTarget:movieWriter]; AVAsset* videoAsset = [AVAsset assetWithURL:InputURL]; AVAssetTrack *assetVideoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo]firstObject];
movieWriter.transform = assetVideoTrack.preferredTransform; // [movie enableSynchronizedEncodingUsingMovieWriter:movieWriter];
[movieWriter startRecording];
[movieFile startProcessing];
[movieFile2 startProcessing];
[movieWriter setCompletionBlock:^{ dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@"movieWriter Completion");
handler(outPutVideoUrl,1);
});
}];
}
5.使用 GPUImageUIElement 将序列帧资源合并在目标资源上
#pragma mark GPUImageUIElement+ (void)addWaterMarkTypeWithGPUImageUIElementAndInputVideoURL:(NSURL*)InputURL WithCompletionHandler:(void(^)(NSURL* outPutURL, intcode))handler{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyyMMddHHmmss"; NSString *outPutFileName = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]]; NSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mov",outPutFileName]]; NSURL* outPutVideoUrl = [NSURL fileURLWithPath:myPathDocs];
GPUImageMovie* movieFile = [[GPUImageMovie alloc] initWithURL:InputURL];
NSValue *value = [NSValue valueWithCGRect:CGRectMake([UIScreen mainScreen].bounds.size.width/2.0- (332/2.0) , [UIScreen mainScreen].bounds.size.height/2.0- (297/2.0) , 332, 297)]; NSValue *value2 = [NSValue valueWithCGAffineTransform:CGAffineTransformMake(1, 0, 0, 1, 0, 0)]; UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
GPUImageFilterGroup* filter = [WatermarkEngine addWatermarkWithResourcesNames:@[@"雨天青蛙"] Andframes:@[value] AndTransform:@[value2] AndLabelViews:@[view]];
[movieFile addTarget:filter];
GPUImageMovieWriter* movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:outPutVideoUrl size:CGSizeMake(540, 960) fileType:AVFileTypeQuickTimeMovie outputSettings: @
{ AVVideoCodecKey: AVVideoCodecH264, AVVideoWidthKey: @540, //Set your resolution width here
AVVideoHeightKey: @960, //set your resolution height here
AVVideoCompressionPropertiesKey: @
{ //2000*1000 建议800*1000-5000*1000
//AVVideoAverageBitRateKey: @2500000, // Give your bitrate here for lower size give low values
AVVideoAverageBitRateKey: @5000000, AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel, AVVideoAverageNonDroppableFrameRateKey: @30,
},
}
];
[filter addTarget:movieWriter]; AVAsset* videoAsset = [AVAsset assetWithURL:InputURL]; AVAssetTrack *assetVideoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo]firstObject];
movieWriter.transform = assetVideoTrack.preferredTransform; // [movie enableSynchronizedEncodingUsingMovieWriter:movieWriter];
[movieWriter startRecording];
[movieFile startProcessing];
[movieWriter setCompletionBlock:^{ dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@"movieWriter Completion");
handler(outPutVideoUrl,1);
});
}];
}
+ (GPUImageFilterGroup*) addWatermarkWithResourcesNames:(NSArray* )resourcesNames Andframes:(NSArray*)frams AndTransform:(NSArray*)transforms AndLabelViews:(NSArray*)labelViews{
__block intcurrentPicIndex = 0; CGFloat width = CGRectGetWidth([UIScreen mainScreen].bounds); UIView* temp = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
[temp setContentScaleFactor:[[UIScreen mainScreen] scale]];
__block UIImageView* waterImageView1 = [[UIImageView alloc] init];
__block UIImageView* waterImageView2 = [[UIImageView alloc] init];
__block UIImageView* waterImageView3 = [[UIImageView alloc] init]; for(intindex = 0; index < resourcesNames.count ; index++) { if(index == 0) {
waterImageView1.frame = [frams[index] CGRectValue]; UIImage* tempImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@_d",resourcesNames[index],currentPicIndex] ofType:@"png"]];
waterImageView1.image = tempImage;
waterImageView1.transform = [transforms[index] CGAffineTransformValue];
[temp addSubview:waterImageView1];
[temp addSubview:labelViews[index]];
}elseif(index == 1){
waterImageView2.frame = [frams[index] CGRectValue]; UIImage* tempImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@_d",resourcesNames[index],currentPicIndex] ofType:@"png"]];
waterImageView2.image = tempImage;
waterImageView2.transform = [transforms[index] CGAffineTransformValue];
[temp addSubview:waterImageView2];
[temp addSubview:labelViews[index]];
}else{
waterImageView3.frame = [frams[index] CGRectValue]; UIImage* tempImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@_d",resourcesNames[index],currentPicIndex] ofType:@"png"]];
waterImageView3.image = tempImage;
waterImageView3.transform = [transforms[index] CGAffineTransformValue];
[temp addSubview:waterImageView3];
[temp addSubview:labelViews[index]];
}
}
GPUImageFilterGroup* filterGroup = [[GPUImageFilterGroup alloc] init];
GPUImageUIElement *uiElement = [[GPUImageUIElement alloc] initWithView:temp];
GPUImageTwoInputFilter* blendFilter = [[GPUImageTwoInputFilter alloc] initWithFragmentShaderFromString:[WatermarkEngine loadShader:@"AlphaBlend_Normal"extension:@"frag"]];
GPUImageFilter* filter = [[GPUImageFilter alloc] init];
GPUImageFilter* uiFilter = [[GPUImageFilter alloc] init];
[uiElement addTarget:uiFilter];// [uiFilter setInputRotation:kGPUImageRotateLeft atIndex:0];
[filter addTarget:blendFilter];
[uiFilter addTarget:blendFilter];
[filterGroup addFilter:filter];
[filterGroup addFilter:uiFilter];
[filterGroup addFilter:blendFilter];
[filterGroup setInitialFilters:@[filter]];
[filterGroup setTerminalFilter:blendFilter]; // 71
// __unsafe_unretained typeof(self) this = self;
[filter setFrameProcessingCompletionBlock:^(GPUImageOutput * filter, CMTime frameTime) {
currentPicIndex += 1;
for(intindex = 0; index < resourcesNames.count ; index++) { if(index == 0) {
waterImageView1.image = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@_d",resourcesNames[index],currentPicIndex] ofType:@"png"]];
}elseif(index == 1){
waterImageView2.image = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@_d",resourcesNames[index],currentPicIndex] ofType:@"png"]];
}else{
waterImageView3.image = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@_d",resourcesNames[index],currentPicIndex] ofType:@"png"]];
}
}
if(currentPicIndex == 89) {
currentPicIndex = 0;
}
[uiElement update];
}];
returnfilterGroup;
}
1
2
+ (NSString * _Nonnull)loadShader:(NSString *)name extension:(NSString *)extenstion { NSURL *url = [[NSBundle mainBundle] URLForResource:name withExtension:extenstion]; return[NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
}
相关推荐
- 全局和隐式 using 指令详解(全局命令)
-
1.什么是全局和隐式using?在.NET6及更高版本中,Microsoft引入了...
- 请停止微服务,做好单体的模块化才是王道:Spring Modulith介绍
-
1、介绍模块化单体是一种架构风格,代码是根据模块的概念构成的。对于许多组织而言,模块化单体可能是一个很好的选择。它有助于保持一定程度的独立性,这有助于我们在需要的时候轻松过渡到微服务架构。Spri...
- ASP.NET程序集引用之痛:版本冲突、依赖地狱等解析与实战
-
我是一位多年后端经验的工程师,其中前几年用ASP.NET...
- .NET AOT 详解(.net 6 aot)
-
简介AOT(Ahead-Of-TimeCompilation)是一种将代码直接编译为机器码的技术,与传统的...
- 一款基于Yii2开发的免费商城系统(一款基于yii2开发的免费商城系统是什么)
-
哈喽,我是老鱼,一名致力于在技术道路上的终身学习者、实践者、分享者!...
- asar归档解包(游戏arc文件解包)
-
要学习Electron逆向,首先要有一个Electron开发的程序的发布的包,这里就以其官方的electron-quick-start作为例子来进行一下逆向的过程。...
- 在PyCharm 中免费集成Amazon CodeWhisperer
-
CodeWhisperer是Amazon发布的一款免费的AI编程辅助小工具,可在你的集成开发环境(IDE)中生成实时单行或全函数代码建议,帮助你快速构建软件。简单来说,AmazonCodeWhi...
- 2014年最优秀JavaScript编辑器大盘点
-
1.WebstormWebStorm是一种轻量级的、功能强大的IDE,为Node.js复杂的客户端开发和服务器端开发提供完美的解决方案。WebStorm的智能代码编辑器支持JavaScript,...
- 基于springboot、tio、oauth2.0前端vuede 超轻量级聊天软件分享
-
项目简介:基于JS的超轻量级聊天软件。前端:vue、iview、electron实现的PC桌面版聊天程序,主要适用于私有云项目内部聊天,企业内部管理通讯等功能,主要通讯协议websocket。支持...
- JetBrains Toolbox推出全新产品订阅授权模式
-
捷克知名软件开发公司JetBrains最为人所熟知的产品是Java编程语言开发撰写时所用的集成开发环境IntelliJIDEA,相信很多开发者都有所了解。而近期自2015年11月2日起,JetBr...
- idea最新激活jetbrains-agent.jar包,亲测有效
-
这里分享一个2019.3.3版本的jetbrains-agent.jar,亲测有效,在网上找了很多都不能使用,终于找到一个可以使用的了,这里分享一下具体激活步骤,此方法适用于Jebrains家所有产品...
- CountDownTimer的理解(countdowntomars)
-
CountDownTimer是android开发常用的计时类,按照注释中的说明使用方法如下:kotlin:object:CountDownTimer(30000,1000){...
- 反射为什么性能会很慢?(反射时为什么会越来越长)
-
1.背景前段时间维护一个5、6年前的项目,项目总是在某些功能使用上不尽人意,性能上总是差一些,仔细过了一下代码发现使用了不少封装好的工具类,工具类里面用了好多的反射,反射会影响到执行效率吗?盲猜了一...
- btrace 开源!基于 Systrace 高性能 Trace 工具
-
介绍btrace(又名RheaTrace)是抖音基础技术团队自研的一款高性能AndroidTrace工具,它基于Systrace实现,并针对Systrace不足之处加以改进,核心改进...
你 发表评论:
欢迎- 一周热门
- 最近发表
-
- .NET 奇葩问题调试经历之3——使用了grpc通讯类库后,内存一直增长......
- 全局和隐式 using 指令详解(全局命令)
- 请停止微服务,做好单体的模块化才是王道:Spring Modulith介绍
- ASP.NET程序集引用之痛:版本冲突、依赖地狱等解析与实战
- .NET AOT 详解(.net 6 aot)
- 一款基于Yii2开发的免费商城系统(一款基于yii2开发的免费商城系统是什么)
- asar归档解包(游戏arc文件解包)
- 在PyCharm 中免费集成Amazon CodeWhisperer
- 2014年最优秀JavaScript编辑器大盘点
- 基于springboot、tio、oauth2.0前端vuede 超轻量级聊天软件分享
- 标签列表
-
- mybatis plus (70)
- scheduledtask (71)
- css滚动条 (60)
- java学生成绩管理系统 (59)
- 结构体数组 (69)
- databasemetadata (64)
- javastatic (68)
- jsp实用教程 (53)
- fontawesome (57)
- widget开发 (57)
- vb net教程 (62)
- hibernate 教程 (63)
- case语句 (57)
- svn连接 (74)
- directoryindex (69)
- session timeout (58)
- textbox换行 (67)
- extension_dir (64)
- linearlayout (58)
- vba高级教程 (75)
- iframe用法 (58)
- sqlparameter (59)
- trim函数 (59)
- flex布局 (63)
- contextloaderlistener (56)