Simplest way to set a background image on a ProMotion screen?

280 views Asked by At

I just want to set a background image on a screen for a placeholder. What is the quickest, easiest, simplest way to do that? Everything I've tried does not seem to work.

I should mention that this is in RedPotion so I already have access to RMQ.

1

There are 1 answers

5
Gant Laborde On BEST ANSWER

I do exactly this in RedPotion for my RubyTrivia app. Simply set your root_view style for your given RedPotion stylesheet. In this case I'm setting the background image to an image resource.

# In an RMQ Stylesheet
def root_view(st)
  st.background_image = image.resource('retina_wood')
end

# In a ProMotion Screen
def on_load
  find(view).style {|st| st.background_image = image.resource('retina_wood') }
end

Note that the RMQ implementation of background_image= sets the background to be a tiling (repeating) background image. So if you want to fill the screen, you will want to use a different approach as it will look differently on different sized screens. My RubyTrivia app is open source, so please enjoy! https://github.com/IconoclastLabs/rubytrivia