Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

请问大家有发现svga添加在window上加载不出来的情况 #164

Open
Legendgp opened this issue Jul 9, 2021 · 2 comments
Open

Comments

@Legendgp
Copy link

Legendgp commented Jul 9, 2021

Attention

  • Do not ask any usage question, issue board is a issue board, accept library bugs only.
  • If you are facing any usage problem, read the README again.

Issue Template

Issue Description(What's your problem)

How To Reappear(How to reappear the issue)

Any Attachment(Provide a sample about your issue)

------ 中文分割线 ------

注意

  • 不要在 Issue 板块提问使用问题,Issue 板块只接受 Bug 反馈。
  • 如果遇到使用上的问题,仔细阅读 README。

Issue 模板

请尽量使用英文提交 Issue

请确切回答:问题的描述、重现方式、附件(提供一个 Demo 以重现问题)

@yangqingren
Copy link
Contributor

你好,请提供相应的代码片段和 svga 素材

@Legendgp
Copy link
Author

Legendgp commented Jul 10, 2021

你好,烦劳测试

素材:
starlight.svga.zip

代码如下:

import UIKit
class TestViewController: UIViewController {

lazy var player: SVGAPlayer = {
    let player = SVGAPlayer.init(frame: CGRect.init(x: 100, y: 200, width: 200, height: 108))
    player.isUserInteractionEnabled = true
    
    let parser = SVGAParser.init()
    let url = NSURL.fileURL(withPath: Bundle.main.path(forResource: "starlight", ofType: "svga")!)
    parser.parse(with: url) { [weak self] videoItem in
        guard let self = self else { return }
        self.player.videoItem = videoItem
        self.player.startAnimation()
    } failureBlock: { error in}
    return player
}()
override func viewDidLoad() {
    super.viewDidLoad()
    //view.window?.addSubview(player)//window上无法加载出svga文件
    view.addSubview(player)//view上可以加载出来
}

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants