Skip to main content

From Remote URL

PhotoEditor SDK supports adding custom frames from the app bundle. In this example, we add dynamic frames. However, it is also possible to add static frames with a fixed aspect ratio in an analogous fashion.

In order to add custom frames, we need to create a CustomPatchConfiguration object which will hold the data necessary for the CustomPatchFrameBuilder to render a frame.

Image Groups#

Dynamic frames consist of four groups, corresponding to each side of the frame. In our example, we opt for the "horizontal inside" mode of arranging image tiles providing only a middle image for the left and right parts of the frame and a start, middle and end image for the top and bottom parts. Refer to the guide on dynamic frames for an in-depth explanation. The frame tool is optimized for remote resources which allows integration of remote URLs directly with the use to download them beforehand. For an example of how to download the remote resources in advance and use the local downloaded resources, refer to the guide on adding fonts from a remote URL. These groups are then added to the CustomPatchConfiguration initialized above.

Image Modes#

By default, the midImageMode is set to .repeat which repeats the middle image to fill out the entire space. For this example, it is set to .stretch for all image groups to keep the correct pattern. In this mode, the middle image is stretched to fill out the entire space.

Initialize Frame#

Next, we pass the frame configuration to a CustomPatchFrameBuilder responsible for rendering the frame. The builder in turn is passed to the Frame constructor, as well as a thumbnailURL for display in the UI and an identifier. The frame identifier needs to be unique since it is used during the (de)serialization process.

Add to Asset Catalog#

Finally, we add the custom frame to the assetCatalog by appending it to the frames property.