

TextTitle.text = "My workout on 05/26/22" Let textTitle = storyTemplateStats.textLayer(named: "workout-title") Let imgProfile = storyTemplateStats.pictureLayer(named: "user") Let textCalBurned = storyTemplateStats.textLayer(named: "cal-burned") Let textKgLifted = storyTemplateStats.textLayer(named: "kg-lifted") Let textHeartrate = storyTemplateStats.textLayer(named: "heartrate") Let textWorkoutTime = storyTemplateStats.textLayer(named: "workout-time") You can find all properties in our API documentation! In our example, we're only changing their content (text and image URLs), but Placid also offers customization of colors, borders, visibility and more. To do so, we have to call the dynamic layers of our template and use their properties to modify them. To our stats-focused template we'll add some statistics from the user's workout, their profile pic and the title of the image including the current date.

Now we're ready to fill our data into the dynamic layers of our templates to render a personalized images for our users. StoryTemplateSelfie.preload() Modify your layer data Let storyTemplateSelfie = PlacidSDK.template(withIdentifier: "mklwbrwiq") Let storyTemplateStats = PlacidSDK.template(withIdentifier: "vazi5xoof") For faster rendering, we recommend preloading them. Retrieve and preload your templateįind the IDs of your template in the Template menu in your Placid project to retrieve it. In the next steps we're going to call one of our templates and generate an image with custom values from it. extension UIView Generate images from Placid templates in Swift

#Swift share code
Of course I'm a bit partial to our SDK 🙃 but if you prefer a self-coded solution, you would need to code custom UIViews with the layouts of your share image designs, and then render them as a UIImage. Alternative: Create share images using UIViews rendered as UIImages The setup takes only a few minutes, and you'll be able to generate unlimited images (offline and directly on-device, no API calls needed).
#Swift share how to
We want to help you as app devs & designers to implement fancy and flexible social sharing: In this article, I'm going to show you how to generate dynamic share images from (easy to design) templates in Swift with the Placid iOS SDK. That way, one user might bring you two more without having to spend any $ on ads. It's always best to make it as easy as possible for users to share their accomplishments and (self-created) content directly from within our apps. Adding social sharing to your apps can drive virality and organic growth.
