提交 dda89f66 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

修改 iOS Lottie 插件读取资源文件的方式

上级 16afebf0
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<button @tap="changeAction(3)">测试action stop</button> <button @tap="changeAction(3)">测试action stop</button>
<animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action" <animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action"
:hidden="hidden" @bindended="testAnimEnd" @click="lottieClickTest" @longpress="lottieLongpressTest" :hidden="hidden" @bindended="testAnimEnd" @click="lottieClickTest" @longpress="lottieLongpressTest"
:style="{width:widthNum+'px',height:heightNum+'px',background:yanse}"> :style="{width:widthNum+'rpx',height:heightNum+'px',background:yanse}">
</animation-view> </animation-view>
</div> </div>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
action: "play", action: "play",
loop: false, loop: false,
yanse: "red", yanse: "red",
widthNum: 375, widthNum: 750,
heightNum: 200, heightNum: 200,
comShow: true, comShow: true,
animUrl: "anim_a.json" animUrl: "anim_a.json"
...@@ -39,10 +39,10 @@ ...@@ -39,10 +39,10 @@
this.autoplay = !this.autoplay this.autoplay = !this.autoplay
}, },
changeUrl: function() { changeUrl: function() {
if (this.animUrl == "anim_a.json") { if (this.animUrl == "/static/anim_a.json") {
this.animUrl = "anim_b.json" this.animUrl = "/static/anim_b.json"
} else { } else {
this.animUrl = "anim_a.json" this.animUrl = "/static/anim_a.json"
} }
}, },
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
} from 'Foundation' } from 'Foundation'
import { import {
UIView UIView
} from "UIKit" } from "UIKit"
import { UTSiOS } from "DCloudUTSFoundation"
//原生提供以下属性或方法的实现 //原生提供以下属性或方法的实现
...@@ -159,10 +160,8 @@ ...@@ -159,10 +160,8 @@
if (this.path.hasPrefix("http")) { if (this.path.hasPrefix("http")) {
animationUrl = new URL(string = this.path) animationUrl = new URL(string = this.path)
} else { } else {
var filePath = Bundle.main.path(forResource = this.path, ofType = null) const filePath = UTSiOS.getResourcePath(this.path)
if (filePath != null) { animationUrl = new URL(fileURLWithPath = filePath)
animationUrl = new URL(fileURLWithPath = filePath!)
}
} }
if (animationUrl != null) { if (animationUrl != null) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册