即使在分配内容后,创建的图层也是空的(Layer created is empty even after assigning content to it)

编程入门 行业动态 更新时间:2024-10-27 04:24:57
即使在分配内容后,创建的图层也是空的(Layer created is empty even after assigning content to it)

我只是试着按照这个教程做一个快速原型:

https://www.youtube.com/watch?v=3zaxrXK7Nac

我正在使用我自己的设计,问题如下:

当我创建time 8:13 of the posted video的新图层time 8:13 of the posted video ,我试图通过使用属性image将我的一个导入图层设置为此新图层的内容,但没有任何结果。

如果我将这个新图层带到屏幕上,根据教程,我只能看到具有透明度的黑色背景,它应该有我通过图像属性分配给它的图层。

这是我的代码的一个例子:

sketch = Framer.Importer.load("imported/Untitled@2x") explore_layer = new Layer width: 750 height: 1334 image: sketch.explore.explore_group x: screen.width sketch.Tab_3.on Events.Click, -> explore_layer.animate properties: x: 0 y: 0 curve: "spring(400, 35, 0)"

这里也是我的图层的截图

https://gyazo.com/f3fccf7f38813744ea17d259463fabdc

I just trying to do a quick prototype following this tutorial:

https://www.youtube.com/watch?v=3zaxrXK7Nac

I'm using my own design for this, the problem is as follows:

When I create a new layer time 8:13 of the posted video and I try to set one of my imported layers as the content of this new layer by using the property image, I get no results.

If I bring this new layer to the screen I can only see black background with transparency, according to the tutorial, it should has the layer I'm assign to it via the image property.

Here is an example of my code:

sketch = Framer.Importer.load("imported/Untitled@2x") explore_layer = new Layer width: 750 height: 1334 image: sketch.explore.explore_group x: screen.width sketch.Tab_3.on Events.Click, -> explore_layer.animate properties: x: 0 y: 0 curve: "spring(400, 35, 0)"

Here is also a screenshot of my layers

https://gyazo.com/f3fccf7f38813744ea17d259463fabdc

最满意答案

Framer将始终将所选组中的所有组导入Sketch中,并且该页面上的所有组将转换为直接在草图对象上可用的图层。 另外:您现在将图层的图像设置为图层对象本身,而不是草图图层。

所以为了使它起作用,你需要做几件事情:

在Sketch中将所有要使用的元素放在同一页面上 导入后,直接从草图对象访问这些元素(如sketch.explore_group而不是sketch.explore.explore_group ) 使用草图图层的图像,或在原型中使用草图图层本身。

下面是一个例子:

sketch = Framer.Importer.load("imported/Untitled@2x") explore_layer = new Layer width: 750 height: 1334 image: sketch.explore_group.image x: screen.width sketch.Tab_3.on Events.Click, -> explore_layer.animate properties: x: 0 y: 0 curve: "spring(400, 35, 0)"

甚至更短,并使用更新的动画语法 :

sketch = Framer.Importer.load("imported/Untitled@2x") sketch.explore_group.x = screen.width sketch.Tab_3.on Events.Click, -> sketch.explore_group.animate x: 0 y: 0 options: curve: Spring(tension:400, friction:35)

Framer will always import the groups in the selected page of Sketch, and all the groups on that page will transformed into layers that are available on the sketch object directly. Also: you're now setting the image of a layer to a layer object itself, instead of the image of the sketch layer.

So to get it to work, you need to do a couple of things:

Place all the elements that you want to use on the same page in Sketch After importing, access those elements directly from the sketch object (so sketch.explore_group instead of sketch.explore.explore_group) Use the image of the sketch layer, or use the sketch layer itself in your prototype.

Here's an example how it that would look:

sketch = Framer.Importer.load("imported/Untitled@2x") explore_layer = new Layer width: 750 height: 1334 image: sketch.explore_group.image x: screen.width sketch.Tab_3.on Events.Click, -> explore_layer.animate properties: x: 0 y: 0 curve: "spring(400, 35, 0)"

Or even shorter, and with an updated animation syntax:

sketch = Framer.Importer.load("imported/Untitled@2x") sketch.explore_group.x = screen.width sketch.Tab_3.on Events.Click, -> sketch.explore_group.animate x: 0 y: 0 options: curve: Spring(tension:400, friction:35)

更多推荐

本文发布于:2023-07-22 18:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222279.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图层   分配   内容   Layer   content

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!