Scrolling » Quickly adding content
Quickly adding content
A tip: You can use a for…in
loop to quickly create content.
Let’s create the content layers again with a loop:
# Add 6 content layers
for index in [0...6]
layer = new Layer
parent: scroll.content
backgroundColor: "#7DDD11"
width: 341, height: 200, borderRadius: 10
x: 16
y: 216 * index
We placed every consecutive layer 200 + 16 points lower than the last by multiplying 216
by the current index
value.