beetlebug▾
/

ztk::ios::Image

Makes an image view (UIImageView) that shows a Tk photo at the width of its column.

Synopsis

ztk::ios::Image new ?OPTION VALUE ...?
$screen add image ?OPTION VALUE ...?

Arguments

Name Type Default Description
-image photo empty The name of a photo of image create photo. The view copies its pixels when the option is set, so a later change of the photo needs the option again. The -density of the photo gives its size: a photo of 200 by 100 pixels at density 2 is 100 by 50 points. Empty shows no image.
-fit fit, fill, stretch fit fit shows the whole photo with its shape, fill covers the view with its shape and clips the rest, and stretch covers the view and changes the shape.
-height integer 0 The height of the view in points. 0 gives the view the shape of the photo at the width of the column.
-hidden, -accessibilityLabel, -accessibilityHint option As for each view (ztk::ios).
configure, cget, destroy method As for each object (ztk::ios).

Return value

new gives the object.

Errors

Error When
image "NAME" doesn't exist -image names no photo.
image "NAME" is empty The photo has no pixels.
bad fit "X": must be fill, fit, or stretch -fit has another value.
bad height "X": must be a number of points from 0 to 100000 -height is no integer, or is out of the range.
unknown option "-X": must be ... Another option.

Platforms

Platform Works
Windows No
macOS No
Linux, Wayland No
Linux, X11 No
Web No
iOS Yes
Android No: ztk::android::Image
Headless With --fake-native ios: fake views for a test (Test on a desktop).

Example

set photo [image create photo -width 300 -height 150]
$photo put #3a7bd5 -to 0 0 300 150
set screen [ztk::ios::Screen new -title Trip]
$screen add image -image $photo -fit fill -height 160 -accessibilityLabel "The sea at dusk"
$screen add label -text "Three days by the sea."
ztk::ios::app root $screen

See also