layer.image < string>
Sets the background-image url or path for this layer. You can set it as a local path or a full url. The image will always fit to cover the layer, and will never be stretched. You can remove an image by setting it to null or an empty string.
译:设置此图层的背景图片网址或路径。你可以把它设为一个本地路径或一个完整的网址。该图像将永远适合覆盖层,并将永远不会被拉伸。设置一个图像将删除一个图层的背景色。您可以通过将其设置为空或空字符串来删除图像。
# Local images
layerA = new Layer
image: "images/logo.png"
# Hosted images
layerA.image = "http://framerjs.com/logo.png"
Setting an image will remove the default background color of a layer. Set the background color to another color than the default to show it behind the image.
译:设置一个图像将删除一个图层的默认背景颜色。将背景颜色设置为另一种颜色,默认显示在图像后面。
#Show a color where the image is transparent
layerA = new Layer
image: "images/logo.png"
backgroundColor: "blue"
You can be notified of when an image is loaded and ready to display with the Events.ImageLoaded event. If there is an error loading an image (like not found) it will throw an Events.ImageLoadError event.
译:你能被通知当图像被加载并准备与events.imageloaded事件显示。如果有一个错误加载图像(如没有发现)它将抛出一个events.imageloaderror事件。
layerA = new Layer
image: "images/logo.png"
# Listen to the loading event
layerA.on Events.ImageLoaded, ->
print "The image loaded"
layerA.on Events.ImageLoadError, ->
print "The image couldn't be loaded"