Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/ui/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ previous_url: /ui-images,/ui/ui-images

# Working with Images
In this article, we will look at the different ways to show images in a NativeScript application.
Images are added to an application either declaratively (XML) or with code (JS).
Images are added to an application either declaratively (XML) or with code (JS). NativeScript supports images coded as `JPG` or as `PNG`.

> **Note:** NativeScript supports images encoded as `PNG` or `JPG` files.

{% nativescript %}
```XML
<Image src="~/logo.png" />
```
```JavaScript
var image = new imageModule.Image();
let image = new imageModule.Image();
image.src = "~/logo.png";
dockLayout.addChild(image);
```
Expand All @@ -26,7 +28,7 @@ dockLayout.addChild(image);
<Image src="~/logo.png" ></Image>
```
```JavaScript
var image = new imageModule.Image();
let image = new imageModule.Image();
image.src = "~/logo.png";
dockLayout.addChild(image);
```
Expand All @@ -41,8 +43,8 @@ The prefix of the `src` value specifies where the image will be loaded form. The
You can also use the [image-source]({%ns_cookbook image-source%}) module to create an image source and manually set it to the image:

```JavaScript
var image = new imageModule.Image();
var imageSource = imageSourceModule.fromResource("logo");
let image = new imageModule.Image();
let imageSource = imageSourceModule.fromResource("logo");
image.imageSource = imageSource;
```

Expand Down Expand Up @@ -120,4 +122,3 @@ For more information, see [Icon and Image Sizes](https://developer.apple.com/lib

Once the NativeScript project is prepared (`tns prepare ios`) all the images will be copied to the `platforms\ios\<project-name>\Resources`.

**iOS images must be `PNG` or `JPG` files.**