gpt4 book ai didi

ios - 渲染一个 UIView,其中的某些东西被动画化并从中导出视频

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:08:20 25 4
gpt4 key购买 nike

如何像录制手机屏幕的一部分一样从 UIView 录制一段视频?

最佳答案

使用Glimpse

Glimpse 允许您从 UIView 创建视频。此处提供了更多文档,但基本上它通过拍摄一系列 UIView 的屏幕截图,然后创建 quicktime 视频并将其保存到应用程序的文档文件夹中,来记录动画和 Action 。

这是一个示例用法:

#import <Glimpse/Glimpse.h>

@implementation myViewController
- (void)viewDidAppear
{
[super viewDidAppear:animated];

// Create a new Glimpse object.
Glimpse *glimpse = [[Glimpse alloc] init];

// Start recording and tell Glimpse what to do when you are finished
[glimpse startRecordingView:self.view onCompletion:^(NSURL *fileOuputURL) {
NSLog(@"DONE WITH OUTPUT: %@", fileOuputURL.absoluteString);
}];

// Create a subview for this example
UIView *view = [[UIView alloc] initWithFrame:CGRectInset(self.view.bounds, 40.0f 40.0f)];
view.backgroundColor = [UIColor greenColor];
view.alpha = 0.0f;

[self.view addSubview:view];

// We are going to record the view fading in.
[UIView animateWithDuration:5.0 animations:^{
view.alpha = 1.0f;
} completion:^(BOOL finished) {
// Since our animation is complete, lets tell Glimpse to stop recording.
[glimpse stop];
}];
}
@end

关于ios - 渲染一个 UIView,其中的某些东西被动画化并从中导出视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35422154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com