<?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 aybek can kaya on Medium]]></title>
        <description><![CDATA[Stories by aybek can kaya on Medium]]></description>
        <link>https://medium.com/@AybekCan?source=rss-ba427b17c8be------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0ok7wRdSprFlqBZo8oi5wA.jpeg</url>
            <title>Stories by aybek can kaya on Medium</title>
            <link>https://medium.com/@AybekCan?source=rss-ba427b17c8be------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 02:04:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@AybekCan/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[Designing fluid menu view in iOS]]></title>
            <link>https://medium.com/@AybekCan/designing-fluid-menu-view-in-ios-c72accc4df95?source=rss-ba427b17c8be------2</link>
            <guid isPermaLink="false">https://medium.com/p/c72accc4df95</guid>
            <category><![CDATA[uiviewpropertyanimator]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[aybek can kaya]]></dc:creator>
            <pubDate>Mon, 18 May 2020 07:23:51 GMT</pubDate>
            <atom:updated>2020-05-18T07:23:51.998Z</atom:updated>
            <content:encoded><![CDATA[<p>In plenty of applications you may have noticed modal views. Alerts , action sheets or activity views are good examples of modal views that are used in iOS apps. Presenting a modal content can :</p><ul><li>Help to catch user’s attention to desired view.</li><li>Ensuring that people receive and if necessary , act on critical information.</li></ul><p>After iOS 7 , Apple focused on the fluidity of modal views. In this <a href="https://developer.apple.com/videos/play/wwdc2018/803/">video</a> , Apple introduces how they achieve the fluidity in UI. It is one of the best WWDC videos I have ever watched. I highly recommend it.</p><h4><strong>What is fluidity ?</strong></h4><p>It is all about giving high priority to the user. Fluidity wants the user to understand what the system is trying to say. On the other hand with fluidity , application gives more control on the users’ actions. One cool example for fluidity is “swipe to go home” gesture that iPhone X has.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*F_l-8kTtk1H9PlIvPUKBZg.gif" /><figcaption>Swipe to go Home</figcaption></figure><p>With fluid interfaces interactions are responsive, interruptible, and redirectable. This improves user experience.</p><p>In this post , we will build an action sheet like bottom menu. It will be :</p><ul><li><strong>Responsive</strong> : When user swipe up and down , view will respond to user’s action.</li><li><strong>Interruptible</strong> : User can stop animation while the animation is running.</li><li><strong>Redirectable</strong> : Show and hide animation can be toggled while the animation is running.</li></ul><p>Today , we will build an interactive menu like the gif below. For clarity the animation has been slowed down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*7MrDcYtUNSJl_I7vpyjmlg.gif" /></figure><p>Lets Coding :)</p><p>In this project , I have not used any storyboards and xibs. From this <a href="https://medium.com/@AybekCan/how-to-remove-storyboard-in-xcode-11-c58af947c22e">link</a> you may learn how to remove main storyboard if you do not know.</p><p>First of all we should create the “MainViewController” which holds and controls the Interactive Menu view. Interactive Menu will be a separate UIView subclass. So we need to create it too. I do not want to specifically explain how to create them. At the end file structure should be like the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*LjJrmR1yYcl9m16mnMtV8g.png" /></figure><p><strong>UIView+Constraint</strong> : Little and helpful extension to make constraints. You may use it in your projects if you like it.</p><p><strong>InteractiveMenu</strong> : UIView subclass that we will build today.</p><p><strong>TouchView</strong> : UIView subclass that shows screen touches.</p><p><strong>MainViewController</strong> : UIViewController subclass that holds and controls our interactive menu.</p><p><strong>BottomVC</strong> : UIViewController subclass that will be shown in the Interactive Menu’s container view.</p><p>Open “InteractiveMenu.swift” file and change it like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4711c8db377b692a661f088a224b18f0/href">https://medium.com/media/4711c8db377b692a661f088a224b18f0/href</a></iframe><ol><li>The height addition amount to container view. Due to damping value , At the showing state , this amount prevents the space at the bottom.</li></ol><p>2a,2b. Static values for creating UIViewPropertyAnimator object.</p><p>3. Configuration class that holds basic configuration values of interactive menu like height , background color.</p><p>4a,4b. Frames of container view at the opened and closed positions. They are calculated depending on the height of container view.</p><p>5. All the animations will be done with UIViewPropertyAnimator. This variable holds the instance of the animator.</p><p>6. We will see it at the end of this article. Briefly , this variable holds a scrollable content.</p><p>Now we can continue with setting up the user interface. Add the following code to the end of “InteractiveMenu.swift” file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47121d4472fc5b2195858d01f74258e0/href">https://medium.com/media/47121d4472fc5b2195858d01f74258e0/href</a></iframe><ol><li>For designing , I have used frames instead of auto layout constraints. I would prefer constraints for code simplicity. However when animating with constraints, I have observed some glitches. For smooth animations using frames gives better results.</li><li>This block gets the scrollable content that is embedded in container view if there is any.</li><li>InstantPanGesture is the custom gesture recognizer that extended from UIPanGestureRecognizer. Implementation is like the below.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f0760fc94e9e8bddb41060a5f2767f6/href">https://medium.com/media/3f0760fc94e9e8bddb41060a5f2767f6/href</a></iframe><p>I have subclassed UIPanGesture in order to make it responsive to touches on container view. As you know , pan gesture detected when you hold and move your finger on a view. But for interactive menu we need to detect pan gesture when user touches on the content view. InstantPanGesture makes this possible. If you want to learn about custom gestures , you may read <a href="https://medium.com/swlh/custom-gesture-recognizers-in-ios-15b72ed7a7e5">this</a> article that I have written.</p><p>4. Observer to detect content offset changes on the scrollable content view. This is needed to set content offset to zero when user pull downs the content view. (We will see it in the next lines)</p><h4>Show / Hide menu</h4><p>In order to hide and show the menu view add the following extension code to the InteractiveMenu.swift file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e7e2bd3587ec1099ac48f869f99d03a/href">https://medium.com/media/4e7e2bd3587ec1099ac48f869f99d03a/href</a></iframe><ol><li>When any pan gesture recognized , animations should stop if there is any running animation. If we do not stop the animation , when pan gesture ends animation continues. So it breaks redirectability and interruptibility of fluid animation.</li><li>At the end of the pan gesture ,we should get the velocity of movement. We need this variable to determine the speed and direction of movement. If the velocity is negative , the view is opening ; otherwise closing.</li><li>This variable limits the speed of pan gesture movement. If velocity is smaller than the threshold , then no initial velocity added to animator.</li><li>Rubber banding is a resistance of movement when user tries to make invalid actions. One example for rubber banding is the UIScrollView. When scroll reaches its content limit , it prevents to move further.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*xUT-2uaK9dND3uPczJFJMg.gif" /></figure><p>5. This function calculates the distance between container view and next position depends on the velocity value. If velocity is positive it returns the distance between closing point and container view , otherwise it returns the distance between opening point and container view. Distance is needed to calculate the desired velocity. This calculation makes animation smoother.</p><p>As you may have noticed that there is a convenience init method for UISpringTimingParameters. I have not written it my self. After reading this <a href="https://medium.com/ios-os-x-development/demystifying-uikit-spring-animations-2bb868446773">article</a> , I have decided to use it in this project. I recommend you to read this article. It gives a good insight about spring animations.</p><p>For now , our interactive menu is ready to use . But there is one more thing. If we want to put a scrollable view into menu, how can two gestures work properly ? So , lets continue …</p><p><strong>Adding Scrollable Content</strong></p><p>After this addition, our menu will be like the below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*sBgFC-HBo4JfOyiq6dVXPA.gif" /></figure><p>Both the view in menu and menu itself will respond to the pan gestures. When table view has reached to its top limit , menu view’s pan gestures should respond to touches.</p><p>For this , first of all we should add UIGestureRecognizerDelegate and “<a href="https://developer.apple.com/documentation/uikit/uigesturerecognizerdelegate/1624208-gesturerecognizer">gestureRecognizer(_:shouldRecognizeSimultaneouslyWith:)</a>” method. With this method , both gesture recognizer can be detected if needed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0eee591790b20713b9a5396f107835f/href">https://medium.com/media/d0eee591790b20713b9a5396f107835f/href</a></iframe><p>Scrollable Content View is the scrollable view that is embedded into menu. In our case , it is the table view. If tableView’s vertical content offset has reached to its top limit , both gestures can be recognizable.</p><p>That’s it .</p><h4><strong>Summary</strong></h4><p>For any designer and developer , user experience is the most important point in application development. For better user experience , your application should give control to user as much as possible. With fluid and interactive animations your users can feel the control on your application. So it is crucial thing that you should consider when developing a mobile application.</p><p>You can download and try full project from here.</p><p><strong>See Also</strong></p><ul><li><a href="https://www.objc.io/issues/12-animations/interactive-animations/">Interactive Animations</a></li><li><a href="https://medium.com/ios-os-x-development/demystifying-uikit-spring-animations-2bb868446773">Demystifying UIKit Spring Animations</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c72accc4df95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to remove Storyboard in Xcode 11]]></title>
            <link>https://medium.com/@AybekCan/how-to-remove-storyboard-in-xcode-11-c58af947c22e?source=rss-ba427b17c8be------2</link>
            <guid isPermaLink="false">https://medium.com/p/c58af947c22e</guid>
            <category><![CDATA[storyboard]]></category>
            <category><![CDATA[xcode11]]></category>
            <category><![CDATA[ios-13]]></category>
            <dc:creator><![CDATA[aybek can kaya]]></dc:creator>
            <pubDate>Tue, 05 May 2020 14:42:39 GMT</pubDate>
            <atom:updated>2020-05-05T14:44:30.332Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are opposed to use storyboards and nibs in iOS development like me ; the first thing that you do is to remove Main.storyboard file when creating a new project. Before Xcode 11 , it was easy to remove storyboards . At this <a href="https://medium.com/ios-os-x-development/ios-start-an-app-without-storyboard-5f57e3251a25">link</a> , it is described step by step for Xcode versions lower than 11. However , in Xcode 11 , we make it in a different way.</p><p>First of all , we will create a “<a href="https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/BuildABasicUI.html">Single View Application</a>” in a usual way. Also notice that , “Storyboard” has been selected for user interface section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ef-_2nQltDQluB5K9daywg.png" /></figure><p>As we have created the new project , the screen should be same as the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gu3KM7OdXXmDA9vr1ewJeQ.png" /></figure><p>There are ViewController.swift and Main.storyboard files that are located in the files section . Remove them. (Delete -&gt; Move To Trash)</p><p>Open the info.plist file . There are two lines called : “Storyboard name” and “Main storyboard file base name”. Remove these lines by clicking on “-” button next to these lines. (When you mouse over the line “-” button will appear)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qf8-IBCW3NhEhpO10SoakQ.png" /></figure><p>Then we can create our first view controller. After that , open SceneDelegate.swift file. Change it like the below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9438dba76f656705b4760241047699e2/href">https://medium.com/media/9438dba76f656705b4760241047699e2/href</a></iframe><p>That is it. Build and run your application. From now on , you do not have to use storyboards.</p><p>Happy Coding :)))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c58af947c22e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic understanding of CADisplayLink]]></title>
            <link>https://medium.com/@AybekCan/basic-understanding-of-cadisplaylink-ae78a5efe976?source=rss-ba427b17c8be------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae78a5efe976</guid>
            <category><![CDATA[chronometer]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[cadisplaylink]]></category>
            <dc:creator><![CDATA[aybek can kaya]]></dc:creator>
            <pubDate>Thu, 13 Jun 2019 22:21:01 GMT</pubDate>
            <atom:updated>2019-06-13T22:21:01.119Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*UHoO0qI_qrlum0muHfUNdA.jpeg" /></figure><p>CADisplayLink is a small class that synchronizes its drawing to screen refresh rate of the display. As you add your displayLink into the run loop , your target function will be called at each screen refresh. Let’s think like this; you have device that re-draws its content ten times in a second. So if you add your displayLink to main run loop , the target function will be called 10 times in a second. Run loop feature is mostly used in game development to draw its content at each frame display time. Suppose you want to animate a game character. You have 10 images of walking . Then you should use screen refresh rate to show each images at appropriate time intervals. At first , it may be hard to understand the usage of displayLink. When I was young , I made flip book cartoons at the corners of the books. Display Link is exactly the same as making flip book cartoon.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FUn-BdBSOGKY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DUn-BdBSOGKY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FUn-BdBSOGKY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/abc0aada41aecca6b5f1723a96f6a7bf/href">https://medium.com/media/abc0aada41aecca6b5f1723a96f6a7bf/href</a></iframe><p>First of all let’s see how to add display link in main run loop.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b18cd3d361ae13fd8c4b23c70a3ebfa5/href">https://medium.com/media/b18cd3d361ae13fd8c4b23c70a3ebfa5/href</a></iframe><p>Implementation of CADisplayLink is the same as adding target to any UIControl. It is simple to implement , but hard to use.</p><p>We will develop two simple applications that use CADisplayLink. Before starting , let’s look into the performance of CADisplayLink in your device. So we will develop a performance app. The main design is like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7Rs-69yBAh1EruuaDhlNQ.png" /></figure><p>It is very straight forward. With auto layout , determine the places of UILabels. I will not get into the details of auto layout here, because it is very huge and different subject.</p><p>At code side :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f40646ea59e045798a572a80c1c9bb4d/href">https://medium.com/media/f40646ea59e045798a572a80c1c9bb4d/href</a></iframe><p>If you run this code in your device you would get app display like :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*PyfHdsd81bQVAikXrKZH5w.gif" /></figure><p>The actual frame rate seems close to 60 fps . It is very good for now. If you same results in your device , then it is very good for you too :)</p><p>As you know the most appropriate screen refresh rate is 60 frames per seconds. Human eye can see more than 60 fps. But above some value , human eye cannot distinguish the frame rate. For an electronic device , it is a trade off between performance and quality. So most of Apple devices aims to reach 60 fps. Let’s get into the applications that we will develop.</p><p>The first application we will develop is a simple chronometer app with a pulsing animation around chronometer label.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*WfKm7J-K7YXr8nOSNY602g.gif" /></figure><p>For simplicity , we will create a wrapper class for CADisplayLink called “DisplayLink”.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2657debbd9c41f1d6b83a090ad59a72a/href">https://medium.com/media/2657debbd9c41f1d6b83a090ad59a72a/href</a></iframe><p>There is a counting label and the pulsing animation layer in the screen. First , we will create the counter label.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2d65374bcf1e2800683370440591433/href">https://medium.com/media/b2d65374bcf1e2800683370440591433/href</a></iframe><p>After running , you should see a screen like this ;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZ8TZ4Qdn0qdykdCMygH1g.png" /></figure><p>Now we should add pulsating layer as a background. After adding pulsating layer we will animate it with display link’s screen refresh.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85e49dcef5218a2826e97a74c5d841a8/href">https://medium.com/media/85e49dcef5218a2826e97a74c5d841a8/href</a></iframe><p>Now we can see that ; counter label is animating . But pulsating pink layer is not moving or animating. Lets animate the pulsating layer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b585ded0cc4d9dfa8d23cdd520c1fa8b/href">https://medium.com/media/b585ded0cc4d9dfa8d23cdd520c1fa8b/href</a></iframe><p>(1) We have created pulsing animation as a struct. “PulseConfiguration” is responsible to hold the dynamic and static values in encapsulated fashion. This decreases the mass of view controller. I strongly suggest that, remove as much code as possible from view controller. By this way you will have more clean and more reusable code. Also by this way , when you want to remove the animation you can delete only one line of code from your view controller.</p><p>(2) in order to make our struct unit testable ; we should add a “currentScale” parameter to scale() function. By this way we can easily test values as it is shown in (2a)</p><p>Thats it :) I hope now you have a basic understanding of the usage of CADisplayLink. In next days , we will make more complex apps that are using CADisplayLink class.</p><p>You may download the source codes from :</p><ul><li><a href="https://github.com/aybekckaya/Chronometer">aybekckaya/Chronometer</a></li><li><a href="https://github.com/aybekckaya/PerformanceApp">aybekckaya/PerformanceApp</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae78a5efe976" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Gesture Recognizers in iOS]]></title>
            <link>https://medium.com/swlh/custom-gesture-recognizers-in-ios-15b72ed7a7e5?source=rss-ba427b17c8be------2</link>
            <guid isPermaLink="false">https://medium.com/p/15b72ed7a7e5</guid>
            <category><![CDATA[instagram]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[gesture-recognizer]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[aybek can kaya]]></dc:creator>
            <pubDate>Fri, 07 Jun 2019 22:21:01 GMT</pubDate>
            <atom:updated>2019-06-18T06:45:29.225Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*xTnOTPMyY6RofG3iKCPIFw.jpeg" /></figure><p>In this article , we will see working principles of <a href="https://developer.apple.com/documentation/uikit/uigesturerecognizer">UIGestureRecognizer </a>and how to make a custom gesture like <a href="https://www.instagram.com/">Instagram</a> “love post” action. After reading this article you will be able to make your own unique gesture recognizers with some easy steps.</p><h4><strong>UIGestureRecognizer</strong></h4><p>First of all , we should look into how UIGestureRecognizer works. As you know , there are some built in gesture recognizers that are popular among any mobile phone user. The most popular gesture is the tap gesture. In every iOS app it is used to gather input from user.</p><p>Let’s guess how Apple implemented tap gesture. Generally , only one finger is used to complete this gesture. User should touch to view element and release her/his finger from screen. If touch-end location is in the bounds of view , then tap gesture should succeed. For detecting screen touch touchesBegan(_:with:) , then for detecting finger-release touchesEnded(_:with:) can be used. In my opinion it has been implemented like this :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a756847d747f7d1c5e980ba06b2ad03/href">https://medium.com/media/6a756847d747f7d1c5e980ba06b2ad03/href</a></iframe><p>There are two types of gestures which are discrete and continuous gestures. Continuous gestures have not a specific pattern such as panning on a view or drawing on screen. In discrete gestures there is a pattern like “Zorro’s Z ” sign or Instagram’s double-tap to like gesture.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F11260276&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fzorro-mask-action-gif-11260276&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2F6f6f35560910f7cd251ce43bf796406e%2Ftenor.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/69bf1e9067b639068a1ce6af88e8542a/href">https://medium.com/media/69bf1e9067b639068a1ce6af88e8542a/href</a></iframe><h4>Instagram’s Double-Tap-To-Like Gesture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*-LKimDORtkJM6I4dNEcGWw.gif" /></figure><p>Besides heart icon at the bottom left corner , you can like a post by double tap on it . Then there will appear a beautiful heart animation. For more realistic simulation ; I have taken a screenshot of a post in Instagram in order to make a background view. I am using iPhone 7 plus. So if you try the demo in different screen dimensions , background image would not fit into screen. I want to apologize because of that.</p><p>Let’s get into coding. Firstly , we will create a new subclass of UIGestureRecognizer called “LikeGestureRecognizer”. Then add the skeleton functions (touches began , moved, ended and cancelled). Now , our class should be look like :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aea41ab16361f99ae4132382be479b04/href">https://medium.com/media/aea41ab16361f99ae4132382be479b04/href</a></iframe><p>From ViewController we may use the gesture recognizer like :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2fec60d8b49ce4e48b7ab43302a9dd3/href">https://medium.com/media/c2fec60d8b49ce4e48b7ab43302a9dd3/href</a></iframe><p>However “handleLikeGesture” is not called for now. Because , we have not implemented gesture’s state setters yet. Let’s add them.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e69629a3a60d18e18602fd1a0a251ac0/href">https://medium.com/media/e69629a3a60d18e18602fd1a0a251ac0/href</a></iframe><p>It is cool. Now , whenever we touch to screen ; “handleLikeGesture” will be called. So , we should add the Instagram’s “like” gesture’s specific code. What we expect ? If we touch screen one after another serially with one finger , gesture should succeed . Otherwise it should fail. How can we do it ? We should have a latest touch time holder. Then check whether time between current touch time and latest touch time is smaller than time threshold value.</p><p>Other than that ; we will hold current status value which have “unknown , fail , success” states. Let’s write the final version of our custom gesture.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9a1aa774ea778b23a3c8220ec1a1235/href">https://medium.com/media/d9a1aa774ea778b23a3c8220ec1a1235/href</a></iframe><h4>Conclusion</h4><p>For final thoughts , it is very straight forward to implement your custom unique gesture recognizer. One simple suggestion from me is that your application should never contains complex gestures. Otherwise you may lose your users. If you add complex gesture recognizers like drawing a tree or drawing a letter shape, your users do not want to make them. Mobile phone users want simple , easily-understood , good looking apps. So your app should be self explanatory.</p><p>One more thing. I have not shown the “heart” animation that is used in this article. Because it is not the subject of custom gesture recognizers. But , for a clue ; I have used core animation with grouping feature. You may see it if you download the project.</p><p>Thanks for reading . Please be free to ask anything about the article. I will be glad to answer them. Also , your reviews are very valuable to me .</p><p>Full project :</p><p><a href="https://github.com/aybekckaya/InstagramLikeGesture">aybekckaya/InstagramLikeGesture</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15b72ed7a7e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/custom-gesture-recognizers-in-ios-15b72ed7a7e5">Custom Gesture Recognizers in iOS</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Synchronizing multiple asynchronous operations]]></title>
            <link>https://medium.com/@AybekCan/synchronizing-multiple-asynchronous-operations-7467a4730d41?source=rss-ba427b17c8be------2</link>
            <guid isPermaLink="false">https://medium.com/p/7467a4730d41</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[dispatchgroup]]></category>
            <category><![CDATA[gcd]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[aybek can kaya]]></dc:creator>
            <pubDate>Fri, 31 May 2019 22:44:52 GMT</pubDate>
            <atom:updated>2019-05-31T22:44:52.978Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*blax4RTK_vjlewQAk2nkLg.jpeg" /></figure><p>In some rare cases , you may want to execute multiple concurrent operations and after all operations finished , you may want to get notified. Uploading or downloading multiple files at once are such good examples for this.</p><p>Three years ago , when we have developed “Tripografy” application with Peakode , I have been faced with same situation. At this app , after user upload images to server ; server creates a video from those images. It was appropriate to uploading images concurrently , rather than chaining image-upload tasks one by one. The first solution that came to my mind was like this :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dd251b0a281804991a324e43bc16107/href">https://medium.com/media/4dd251b0a281804991a324e43bc16107/href</a></iframe><p>For complex async operations , variables like “completedCount” make your code smells. At this time , <a href="https://developer.apple.com/documentation/dispatch/dispatchgroup">DispatchGroup</a> tool comes into rescue. (Another approach would be with OperationQueue. But it is more complex to use comparing to DispatchGroup)</p><p><strong>Dispatch Group</strong></p><p>Dispatch group allows you to execute multiple async operations at the same queue or in different queues that you may sync the behaviors of the tasks. When all items finishes , you get notified with groups’ <a href="https://developer.apple.com/documentation/dispatch/dispatchgroup/2016066-notify">notify</a> completion handler. Two important functions other than“notify” are <a href="https://developer.apple.com/documentation/dispatch/dispatchgroup/1452803-enter">enter</a> and <a href="https://developer.apple.com/documentation/dispatch/dispatchgroup/1452872-leave">leave</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05ae0532b6ef97e0007477f4e976a544/href">https://medium.com/media/05ae0532b6ef97e0007477f4e976a544/href</a></iframe><p>Notice that ; every <a href="https://developer.apple.com/documentation/dispatch/dispatchgroup/1452803-enter">enter</a> has to match with corresponding <a href="https://developer.apple.com/documentation/dispatch/dispatchgroup/1452872-leave">leave</a>. Otherwise , <a href="https://developer.apple.com/documentation/dispatch/dispatchgroup/2016066-notify">notify</a> closure will get never called.</p><p><strong>Example</strong></p><p>For real life example , we will develop a bulk image downloader. With given image URLs array , it is predicted to download images from web concurrently. After the downloading operation completed , it will notify. In order to achieve notify functionality , we will be using <a href="https://developer.apple.com/documentation/dispatch/dispatchgroup">DispatchGroup</a>. As well , our ImageKit will notify at each image download operation completed. Lets code :)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fc539f134172bdc7db91d32c4efb819/href">https://medium.com/media/9fc539f134172bdc7db91d32c4efb819/href</a></iframe><p><strong>Conclusion</strong></p><p>For the sake of simplicity , error cases not implemented in our code . But I highly recommend you to implement error cases in functions. Because it may result with more group entries than leaves in your code and notify block may never called.</p><p>Using boolean checkers in your code , makes your code more complicated and hard to maintain. In order to bind multiple async operations , it should be better to use dispatch_groups.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7467a4730d41" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Infinite UIScrollView]]></title>
            <link>https://medium.com/@AybekCan/infinite-uiscrollview-b516a5d14caf?source=rss-ba427b17c8be------2</link>
            <guid isPermaLink="false">https://medium.com/p/b516a5d14caf</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[aybek can kaya]]></dc:creator>
            <pubDate>Mon, 20 May 2019 14:16:00 GMT</pubDate>
            <atom:updated>2019-06-18T16:17:57.418Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GPXk9O3UttIjDZ-vGcAj8Q.png" /></figure><p>In lots of apps, you may faced with a scrollview that never ports itself to the opposite direction at the end of the content size. This technique is very usual for many years, on many platforms. On the other hand, there are lots of third-party libraries to get this effect. You do not really need any third party library. This technique has very simple logic. Trust me :)</p><p>Paging enabled UIScrollView enables the user to view its content page by page. UIScrollView enables this effect by adjusting the scrollView’s offset when the user ends dragging. As user scroll to the end of pages (to the right side), scrollview limits to exceed its content by moving its offset to opposite direction with such beautiful animation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*0vdKH9oXUD0K4k5XGb5VIQ.png" /></figure><p>We want scrollview to not limit its content offset when user wants to exceed its content size. So we need to add two more pages to UIScrollView. The last page will be added to index zero, and the first page will be added to the index (numberOfItems + 1). Then, if the user views the page “numberOfItems” scrollview content offset x is set to 0. If the user views the index of 0, then scrollView content offset x will be set to “pageSize * numberOfItems”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cxjULsgzN8CLB0GP7y0BJw.png" /></figure><p>Let’s coding :)</p><p>The first thing we will be doing is to create a new class that is inherited from UIView.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*6jgFLFEsRFSmFPGT7XRQSQ.gif" /></figure><p>BannerView should be like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77e3ed65879b639e69e0d845e3cb4703/href">https://medium.com/media/77e3ed65879b639e69e0d845e3cb4703/href</a></iframe><p>There is nothing unusual here. Now, we should add the scrollView and setUp code for BannerView:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65ba7291fcf23d9a3dcc4f9c5bd8da45/href">https://medium.com/media/65ba7291fcf23d9a3dcc4f9c5bd8da45/href</a></iframe><p>I have used frames instead of auto layout for simplicity. Also, I have used closures instead of delegates. This helps to avoid dirt from the code at ViewController. With closures, you may simply use bannerView like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbde333f7d235bdef1514ea9abf312b4/href">https://medium.com/media/cbde333f7d235bdef1514ea9abf312b4/href</a></iframe><p>For UIScrollView delegation I will use <strong>scrollViewDidEndDecelerating(_ scrollView: UIScrollView)</strong> instead of <strong>scrollViewDidScroll(_ scrollView: UIScrollView). </strong>Because we do not need to calculate the paging position at each scrollView movement.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3dde855624f3a563626afc4ca812f7e/href">https://medium.com/media/e3dde855624f3a563626afc4ca812f7e/href</a></iframe><p>And finally, our code will be like this for <strong>BannerView.swift:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/945c03ce6350f9602fcf097b0f7e0911/href">https://medium.com/media/945c03ce6350f9602fcf097b0f7e0911/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*oRbuEG__q-9KZMIa5QVeyg.gif" /></figure><p><strong>Summary</strong></p><p>As a summary, we have made a reusable scrollview component with a little logic. By the way, with huge amounts of data, it should be better to use UICollectionView. Because UICollectionView has better performance and better memory management than UIScrollView. Also, you can expand InfiniteScrollView with timing or bidirectional scrolling options. With a little improvement, it would be a really reusable tool for your applications.</p><p>Full Source Code can be found at</p><p><a href="https://github.com/aybekckaya/InfiniteScrollView">aybekckaya/InfiniteScrollView</a></p><p>Happy Coding :))))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b516a5d14caf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>