<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Wendy Abrantes on Medium]]></title>
        <description><![CDATA[Stories by Wendy Abrantes on Medium]]></description>
        <link>https://medium.com/@wendyabrantes?source=rss-55c3647cadf6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*E9ZlOR3lxDY6b16nIZlM8Q.jpeg</url>
            <title>Stories by Wendy Abrantes on Medium</title>
            <link>https://medium.com/@wendyabrantes?source=rss-55c3647cadf6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:24:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wendyabrantes/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Swift UI — Square Image Modifier]]></title>
            <link>https://medium.com/@wendyabrantes/swift-ui-square-image-modifier-3a4370ca561f?source=rss-55c3647cadf6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a4370ca561f</guid>
            <category><![CDATA[viewmodifier]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-13]]></category>
            <dc:creator><![CDATA[Wendy Abrantes]]></dc:creator>
            <pubDate>Wed, 04 Dec 2019 17:43:05 GMT</pubDate>
            <atom:updated>2019-12-04T17:44:40.055Z</atom:updated>
            <content:encoded><![CDATA[<h3>Swift UI — Square Image Modifier</h3><p>I wanted to create a simple List with 2 columns, where the images are square and fit the container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*WnALNgl7wO4kK4chwy1ddQ.png" /><figcaption>SwiftUI — square image</figcaption></figure><p>I start by creating a list view which takes a 2D array parameter for rows and columns. I make the image resizable and set a fixed width and height to get square images.</p><p>This works my images are being scaled, but I want the image to be full width (the parent’s width).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Er2_V9IMohT6-7snIojaeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*HDUCYr_cnExKn7ltCnwy6g.png" /><figcaption>Square Image with fixed width and height</figcaption></figure><p>To get the parent width I can use <strong>GeometryReader</strong>, it’s a container view that gives you access to the size and position of your parent.</p><p>The GeometryReader’s width &amp; height will be equal it’s parent, to get a square image I can set the aspect ratio to 1.</p><pre>GeometryReader { <strong>_</strong> <strong>in<br>  </strong>Image(&quot;\(imageModel.imageUrl)&quot;)<br>  .resizable()<br>  .cornerRadius(4.0)<br>}<br>.aspectRatio(1.0, contentMode: .fit)</pre><p>A square image is a common design, I make this code reusable by creating a <strong>ViewModifier </strong>and an image extension <strong>squareImage().</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*-k9BccQyOVYKeZhpLvr8NA.png" /><figcaption>SquareImage modifier</figcaption></figure><pre>//how to use it </pre><pre>Image(&quot;\(imageModel.imageUrl)&quot;)<br>.resizable()<br>.squareImage()<br>.cornerRadius(4.0)</pre><pre>Image(&quot;\(imageModel.imageUrl)&quot;)<br>.resizable()<br>.ratioImage(1.2)<br>.cornerRadius(4.0)</pre><h4>Thanks!</h4><p>Please find the source code below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f064475c603cde00ee63b809803d738/href">https://medium.com/media/7f064475c603cde00ee63b809803d738/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a4370ca561f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PART 2— Creating a custom animation inspired by InVision Projects Space ]]></title>
            <link>https://medium.com/@wendyabrantes/part-2-creating-a-custom-animation-inspired-by-invision-projects-space-28b9afb80a7e?source=rss-55c3647cadf6------2</link>
            <guid isPermaLink="false">https://medium.com/p/28b9afb80a7e</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[invision]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swift-programming]]></category>
            <dc:creator><![CDATA[Wendy Abrantes]]></dc:creator>
            <pubDate>Fri, 24 Feb 2017 22:52:43 GMT</pubDate>
            <atom:updated>2017-02-26T19:56:28.091Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*HI5Es5A2ybIw2pb4xnAaUA.gif" /></figure><p>This part focuses on creating a custom animation from the cell view to the detail view controller. This is possible by using a custom transition when presenting the detail view controller</p><p>But before getting to deep into the animation code let’s decompose the animation</p><ul><li>the cell frame goes from current to full screen</li><li>the logo goes from being centered in the main image to the center Y being 20% of the main image height</li><li>the main image with a parallax goes full width</li><li>the main image height is 70% of the cell height and goes 50% of the full screen</li><li>project name and number of projects labels fade out</li><li>neighbours cells slide off the screen</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*Eh3UFAfsaGnsWGFmNNauQg.png" /><figcaption>Animation First and Last state</figcaption></figure><p>I’ve refactored the CollectionViewCell to use a CardView object, so the view can be reused in our DetailViewController. Note that CardView also implement NSCopying protocol, this is required to make a clone of our view, needed for the animation.</p><p>I created a protocol CardViewTemplateProtocol who will be responsible for drawing the view in two different states (card state and full screen state).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vgaXG6q2zUGUjG9JSUDvLg.png" /><figcaption>Template Protocol</figcaption></figure><p>In my custom cardView class I create my template object and call the drawRect method on layoutSubviews</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hkmme674va-My93o86yuAQ.png" /><figcaption>redraw CardView</figcaption></figure><p>Now let’s get back to the custom transition.</p><h3>Custom Transition</h3><p>We implement <strong>UIViewControllerTransitioningDelegate</strong> on the InvisionProjectSpaceCollectionViewController.</p><p>When presenting our detail view controller <strong>animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController)</strong> gets called and we return the custom transition class that will be used to <strong>animate in</strong> the detail view controller.</p><p>When dismissing <strong>animationController(forDismissed dismissed: UIViewController) </strong>gets called and we return the custom transition class that will be used to <strong>animate out</strong> the detail view controller</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VAnAGVy3eXCAkNpN14S9wQ.png" /><figcaption>UIViewControllerTransitioningDelegate implementation</figcaption></figure><p>Notice our custom transition class <strong>InvisionProjectSpaceTransition</strong> takes a constructor parameter <strong>isDismissed, </strong>so we know the current presentation state.</p><p>Before getting into the custom transition class it’s important to set the <strong>transitioningDelegate</strong> and the <strong>modalPresentationStyle </strong>of the detail view controller.<strong> </strong>Otherwise the <strong>animationController delegate </strong>won’t be called.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MP7Do6HS72mabPp64upOcg.png" /><figcaption>Set the transitioningDelegate</figcaption></figure><p>Let’s create our custom transition class, we conform to <strong>UIViewControllerAnimatedTransitioning </strong>protocol, and implement the 2 required method, <strong>transitionDuration </strong>and <strong>animateTransition.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oxdeeZTD31bE3E04ABZR_g.png" /></figure><p><strong>animateTransition</strong> is where the magic happen 😆</p><p>We retrieve the <strong>from</strong> and <strong>to</strong> view controller using the transition context. We also have access to a <strong>containerView, </strong>it’s a temporary view in which we can add and animate our views for the duration of the animation. When the animation is done we add the final view to the container and call <strong>transitionContext.completeTransition(true)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VjW7lzEjJWux3VwFEzHJpw.png" /><figcaption>Skeleton of the animation</figcaption></figure><h4>1. presentController Animation</h4><p>First we clone the visible views from the collectionViewController and add them to the containerView, then we animate the selected view to a full screen state and animate the other views to slide off the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KUS145vXWu39raJwys2NVg.png" /><figcaption>Present View Controller Animation</figcaption></figure><p>It’s important to set the options <strong>layoutSubviews</strong> of <strong>UIViewPropertyAnimator</strong>, so the cardView get’s redrawn</p><pre>UIViewPropertyAnimator.runningPropertyAnimator(withDuration: duration,<br>delay: 0.0,<br>options: [.curveEaseOut, .<strong>layoutSubviews</strong>],<br>animations: {..}</pre><h4>//1. clone visible cells and get a reference to the selected cell</h4><p>The helper method return a tuple, the cloned visible cells, and a pointer to the selected cell. We also convert the cell location to a global location so they appear at the exact same location when being added to the containerView.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1I4ePunTQvzS4JlsrWyHw.png" /><figcaption>copyVisisbleCells Helper</figcaption></figure><h4>2. dimissController Animation</h4><p>Dismissing the detail view controller uses the same principle, we do the reverse animation.</p><p>The selected cell goes from a FullScreen template to a CardView template state.</p><p>First we get the visible cells of the toViewController and set the selected view in a full screen mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*umzjVuizGyNF2Sm1P-C0kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrCSZPDTm2ALwCCmwwolUw.png" /></figure><p>That’s it! Hope this article was useful, Like if you enjoyed it! 💪🏾🙏🏾</p><p>The result is pretty slick, from using the same principles you could do all kind of crazy transitions requested by those creative designers 🦄 😎</p><p>You can <a href="https://github.com/wendyabrantes/WAInvisionProjectSpaceExample">download the final project here.</a></p><p><a href="https://github.com/wendyabrantes/WAInvisionProjectSpaceExample">GitHub - wendyabrantes/WAInvisionProjectSpaceExample: A custom animation inspired Invision Projects Space</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28b9afb80a7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PART 1 — Creating a custom animation inspired by InVision Projects Space]]></title>
            <link>https://medium.com/@wendyabrantes/part-1-creating-a-custom-animation-inspired-be-invision-projects-space-65bf83a3b12b?source=rss-55c3647cadf6------2</link>
            <guid isPermaLink="false">https://medium.com/p/65bf83a3b12b</guid>
            <category><![CDATA[swift-3]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[parallax]]></category>
            <category><![CDATA[dribbble]]></category>
            <dc:creator><![CDATA[Wendy Abrantes]]></dc:creator>
            <pubDate>Fri, 24 Feb 2017 22:14:04 GMT</pubDate>
            <atom:updated>2017-02-25T07:48:36.032Z</atom:updated>
            <content:encoded><![CDATA[<p>Last year InVision posted a nice dribble interaction for their iOS app, I don’t think they ever released it in production. This tutorial is an example of how to achieve a similar interaction in Swift 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*HI5Es5A2ybIw2pb4xnAaUA.gif" /><figcaption>Final Interaction</figcaption></figure><p>The interaction contains 2 main parts:</p><p>1. A collection view with a custom layout and a parallax effect on the main image.</p><p>2. A custom view controller transition, that animates the selected cell to the detail view controller.</p><p>In the first part, I’m only going to cover how to achieve the parallax effect of the collection view controller.</p><p>If you’re not familiar with creating a custom layout using UICollectionViewLayout, you should check out Apple’s WWDC videos.</p><p><a href="https://developer.apple.com/videos/play/wwdc2012/219/">Advanced Collection Views and Building Custom Layouts - WWDC 2012 - Videos - Apple Developer</a></p><h3>1. Parallax effect</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*VQ0uBAlIskj3wV23L19ErA.gif" /><figcaption>Part 1 — Parallax Effect</figcaption></figure><p>To achieve the parallax effect we need to understand how layout attribute works.</p><blockquote>An UICollectionViewLayoutAttributes object manages the layout-related attributes for a given item in a collection view. Layout objects create instances of this class when asked to do so by the collection view. In turn, the collection view uses the layout information to position cells and supplementary views inside its bounds.</blockquote><p>We want to add a custom layout attribute “parallaxValue”, so our cell can redraw the main image with a parallax.</p><p>We subclass <strong>UICollectionViewLayoutAttributes</strong> and add a variable named parallaxValue. <strong>UICollectionViewLayoutAttributes </strong>also required to conform to <strong>NSObject, NSCopying.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CRZLHihCrusJuLWqtjIZAg.png" /><figcaption>subclass of UICollectionViewLayoutAttributes</figcaption></figure><p>We need to tell our custom layout to use a custom layout attributes class rather then the default one. So we override layoutAttributesClass to return our custom InvisionCollectionViewLayoutAttributes class.</p><pre>override class var layoutAttributesClass: AnyClass {</pre><pre>return InvisionCollectionViewLayoutAttributes.self</pre><pre>}</pre><p>In the <strong>prepare</strong> method, we pre-calculate each element frame and add it to our custom layout attributes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AB7Bs2foVw7OAK0E6TdseQ.png" /><figcaption>override layoutAttributesClass</figcaption></figure><p>When returning the layout attributes for the current visible rectangle we calculate the parallaxValue and set it to our custom attribute var.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UiNY31Rk0vq1MRDHGUKtPA.png" /><figcaption>calculate parallaxValue attribute</figcaption></figure><p>So far we have our custom layout calculating the parallax value for each cell, now we can use this value in the cell class.</p><p>In our custom cell we override apply(_ layoutAttributes: UICollectionViewLayoutAttributes), when attributes are updated this method is called and we can update mainImageView with a new frame position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eQ_RbU1s4bTKpMYIDbWgLQ.png" /><figcaption>Apply attributes to the cell</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hkfRgfQwsvtN-Zrofc_vdQ.png" /><figcaption>Set the frame position for parallaxValue</figcaption></figure><p>Congratulation! You’ve finished the first part! 💪🏾🙏🏾</p><h4>What’s Next ?</h4><p>Read on how to do a custom view controller transition <a href="https://medium.com/@wendyabrantes/part-2-creating-a-custom-animation-inspired-by-invision-projects-space-28b9afb80a7e#.smwu4rpkh"><strong>Part 2 — Creating a custom animation inspired by InVision Projects Space</strong></a></p><p>I hope you enjoyed this tutorial. You can <a href="https://github.com/wendyabrantes/WAInvisionProjectSpaceExample">download the final project here.</a></p><p><a href="https://github.com/wendyabrantes/WAInvisionProjectSpaceExample">GitHub - wendyabrantes/WAInvisionProjectSpaceExample: A custom animation inspired Invision Projects Space</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65bf83a3b12b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>