The object for adding an image background fill to a component.
- Apple News Format 1.7+
The URL of the image file to use for filling the component.
Image URLs can begin with
bundle://. If the image URL begins with
bundle://, the referenced image file must be in the same directory as the document.
Image filenames should be properly encoded as
URLs. For example, spaces in a URL should be encoded as
%20. See Using Images, Videos, and Audio Files.
Indicates how the image fill should be displayed. Valid values:
fit: Scales the image by aspect ratio to fit the component.
cover:(default): Scales the image by aspect ratio to completely fill the component.
Sets the horizontal alignment of the image fill within its component. Valid values:
left: Aligns the left edge of the fill with the left edge of the component.
center(default): Aligns the horizontal center of the fill with the center of the component.
right: Aligns the right edge of the fill with the right edge of the component.
You can use
horizontal to achieve the effect you want. For example, set
left to fit the image based on its aspect ratio and also align the left edge of the fill with the left edge of the component. Or set
right to scale the image horizontally and also align the right edge of the fill with the right edge of the component.
The type of fill to apply. This property should always be set to
Sets the vertical alignment of the image fill within its component. Valid values:
top: Aligns the top of the fill with the top edge of the component.
center(default): Aligns the vertical center of the fill with the center of the component.
bottom: Aligns the bottom of the fill with the bottom edge of the component.
You can use
vertical to achieve the effect you want. For example, set
top to fit the image based on its aspect ratio and also align the top of the fill with the top edge of the component. Or set
top to scale the image vertically and also align the top of the fill with the top edge of the component.
Image object to fill a component with a background image.
To avoid having the image cut off on different devices, calculate the minimum height needed for the image. For example, the following shows the minimum height calculation of a full display based on an image with dimensions 2184 x 1456 pixels:
100 * (height / width) + “cw”
100 * (1456 / 2184) + “cw”
For more information about the use of cw, see Specifying Measurements for Components.
This object can be used in ComponentStyle.
Create a Layered Effect with a Background
You can create a layered or collage effect by using a background image with a header container component. Create a header that contains the other components you want in the top section of your article, such as the
intro, and then apply a background image to the
header component. All content in the
header component appears in front of the background, creating a layered effect.
Set a Fixed Image Fill
One of the most captivating effects in Apple News Format is the fixed image fill. With this background, the image stays still as the user scrolls, with the rest of the content in the article seeming to move independently of the image. As long as any part of the component containing the image is visible in the viewport, the image remains still.
To create this effect, use a ComponentStyle object with
image as the
fill type, and then give the
attachment property the value of