如何在iOS swift中记录视图的活动?

时间:2017-09-12 10:44:32

标签: ios swift

我正在尝试记录一个视图,即我想要记录的视图上的活动是什么,并将其保存为.mp4。我有一些如何设法记录视图并将录制的视频保存为.mp4到相机胶卷。当我运行项目时,我可以在真实设备上看到动画。

但是发生的事情是在imageView上发生的动画没有得到记录,即我基本上在ImageView上设置了一组图像动画,即我想要记录的视图(ContentView)的子视图。

为了录制我正在使用IAScreenCaptureView库的视图。我正在做的代码如下:

@IBOutlet var contentView: IAScreenCaptureView!
@IBOutlet var mainImageView: UIImageView!
@IBOutlet var animateImageView: UIImageView!

 let myimgArr = ["beauty_01","beauty_02","beauty_03","beauty_04","beauty_05","beauty_06","beauty_07","beauty_08","beauty_09","beauty_10","beauty_11","beauty_12","beauty_13","beauty_14","beauty_15","beauty_16","beauty_17","beauty_18","beauty_19","beauty_20","beauty_21","beauty_22","beauty_23","beauty_24","beauty_25","beauty_26","beauty_27","beauty_28","beauty_29","beauty_30"]

 override func viewDidLoad() {
        super.viewDidLoad()

        animate_images()

    }

 func animate_images()

    {
        var images = [UIImage]()

        for i in 0..<myimgArr.count
        {
            images.append(UIImage(named: myimgArr[i])!)
        }

        animateImageView.animationImages = images
        animateImageView.animationDuration = 2.0
        animateImageView.startAnimating()
        contentView.addSubview(animateImageView)

    }

var t = false
    @IBAction func doneButtonAction(_ sender: UIButton) {

        if t {

            print("Stopped")
            contentView.stopRecording()

        }else {

            print("Started")
            contentView.startRecording()
        }

        t = !t

    }

希望我能够表达自己。在此先感谢任何帮助将受到高度赞赏。

0 个答案:

没有答案