crosvista.blogg.se

Swift share on instagram
Swift share on instagram






  1. #Swift share on instagram how to#
  2. #Swift share on instagram code#

How exactly your share UI works is up to you: You can for example let your users choose between different share image templates or present them a random one each time. Let placidImageSelfie = await storyTemplateSelfie.renderImage()Īnd we're done! Your generated images are now ready to be used for social sharing. let placidImageStats = await storyTemplateStats.renderImage() Once you have filled the layers with your values, you're ready for rendering. ImgSelfie.image = photo // example variable containing an UIImage, picked from the user's library or taken via camera Render images Let imgSelfie = storyTemplateSelfie.pictureLayer(named: "photo")

swift share on instagram

Let textCalBurned = storyTemplateSelfie.textLayer(named: "cal-burned") Let textKgLifted = storyTemplateSelfie.textLayer(named: "kg-lifted") Our second template with the selfie would be filled in a similar way, reusing some of the data. These values are static examples – you would of course use your own variables containing user data here. 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")

swift share on instagram

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.

swift share on instagram

In the next steps we're going to call one of our templates and generate an image with custom values from it.

swift share on instagram

extension UIView Generate images from Placid templates in Swift

#Swift share on instagram 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). Dynamic content layers with auto-resizing for text and images.On-device generation of personalized images from templates.What the Placid mobile integration offers:

#Swift share on instagram 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.








Swift share on instagram