Search code examples
cssnativescriptnativescript-angular

Nativescript, iOS, setting image as background in CSS not working


In my nativescript application I want to set an image as a background with

background-image: url("res://ic_more")

It works on Android, but not on iOS.

This image exists in App_Resources/iOS folder:

enter image description here

And I can even use it in Image like this (red arrow):

<Image src="res://ic_more"></Image>

enter image description here

The problem is somewhere in CSS I believe.

Already tried: tns platform clean ios

Will appreciate any help


Solution

  • Use this code for set background image in android and iOS both.

    <DockLayout stretchLastChild="false">
       <GridLayout rows="*,*" class="page" backgroundImage="~/app/images/home_bg.jpg" backgroundRepeat="no-repeat" backgroundSize="cover" backgroundPosition="center"> 
       </GridLayout>
    </DockLayout>