Christa  Stehr

Christa Stehr

1595684310

Build a GOAT-Inspired Animated Dismissing TabBar: Swift 5 With UIKit

GOAT is a widely used streetwear marketplace app. I use the app all the time and it has been a huge influence on my UI/UX designs. It is minimal, clean, responsive, and easy to use. One thing that has always stood out about it is the dismissing tabBar on scroll. When you scroll down, the tabBar dismisses down. Scroll up, and the tabBar reappears. Here is a demo of what I am talking about:

The way it is integrated into the app is very clean, which enhances my experience with the app.

Using a UICollectionView, here is my implementation of dismissing and presenting the tabBar based on the scroll direction.


Starting the Project

Here is my initial starting project. It is just a simple collectionView with a tabBar:


Determining the Scroll Direction

The first thing we need to do is determine the direction of the scroll. This will allow us to determine whether we dismiss or present the tabBar based on the scroll direction.

We will first declare a variable that will keep track of the previous scroll direction in the class where the collectionView lies. In the case of my project, it is the HomeViewController.

private var prevScrollDirection: CGFloat = 0

Next, since we are using a UICollectionView, we can call the scrollViewDidScrollfunction. This function passes a variable through the function called (scrollView)that will give us the y-offset and the scrollView height. We will compare the previous scroll direction from the y-content offset and the scroll height to check if the user is scrolling up. When they are scrolling down, we will compare the previous scroll vs. the y-content offset and check if the y-content offset is greater than zero.

 func scrollViewDidScroll(_ scrollView: UIScrollView) {
	        let scrollViewY = scrollView.contentOffset.y
	        let scrollSizeHeight = scrollView.contentSize.height
	        let scrollFrameHeight = scrollView.frame.height
	        let scrollHeight = scrollSizeHeight - scrollFrameHeight

	        if prevScrollDirection > scrollViewY && prevScrollDirection < scrollHeight {
	            print("Scroll Up")
	        } else if prevScrollDirection < scrollViewY && scrollViewY > 0 {
	            print("Scroll Down")
	        }

	        prevScrollDirection = scrollView.contentOffset.y
	    }

Using the scrollView function, we can now determine the scroll direction. We print the scroll direction on the console to verify that we are indeed capturing the correct direction.

After we determine the scroll direction, we will store the y-content offset into the prevScrollDirection variable we created.

#uikit #programming #swift #mobile #ios

What is GEEK

Buddha Community

Build a GOAT-Inspired Animated Dismissing TabBar: Swift 5 With UIKit
Christa  Stehr

Christa Stehr

1595684310

Build a GOAT-Inspired Animated Dismissing TabBar: Swift 5 With UIKit

GOAT is a widely used streetwear marketplace app. I use the app all the time and it has been a huge influence on my UI/UX designs. It is minimal, clean, responsive, and easy to use. One thing that has always stood out about it is the dismissing tabBar on scroll. When you scroll down, the tabBar dismisses down. Scroll up, and the tabBar reappears. Here is a demo of what I am talking about:

The way it is integrated into the app is very clean, which enhances my experience with the app.

Using a UICollectionView, here is my implementation of dismissing and presenting the tabBar based on the scroll direction.


Starting the Project

Here is my initial starting project. It is just a simple collectionView with a tabBar:


Determining the Scroll Direction

The first thing we need to do is determine the direction of the scroll. This will allow us to determine whether we dismiss or present the tabBar based on the scroll direction.

We will first declare a variable that will keep track of the previous scroll direction in the class where the collectionView lies. In the case of my project, it is the HomeViewController.

private var prevScrollDirection: CGFloat = 0

Next, since we are using a UICollectionView, we can call the scrollViewDidScrollfunction. This function passes a variable through the function called (scrollView)that will give us the y-offset and the scrollView height. We will compare the previous scroll direction from the y-content offset and the scroll height to check if the user is scrolling up. When they are scrolling down, we will compare the previous scroll vs. the y-content offset and check if the y-content offset is greater than zero.

 func scrollViewDidScroll(_ scrollView: UIScrollView) {
	        let scrollViewY = scrollView.contentOffset.y
	        let scrollSizeHeight = scrollView.contentSize.height
	        let scrollFrameHeight = scrollView.frame.height
	        let scrollHeight = scrollSizeHeight - scrollFrameHeight

	        if prevScrollDirection > scrollViewY && prevScrollDirection < scrollHeight {
	            print("Scroll Up")
	        } else if prevScrollDirection < scrollViewY && scrollViewY > 0 {
	            print("Scroll Down")
	        }

	        prevScrollDirection = scrollView.contentOffset.y
	    }

Using the scrollView function, we can now determine the scroll direction. We print the scroll direction on the console to verify that we are indeed capturing the correct direction.

After we determine the scroll direction, we will store the y-content offset into the prevScrollDirection variable we created.

#uikit #programming #swift #mobile #ios

Houston  Sipes

Houston Sipes

1600430400

10 Free Online Resources To Learn Swift Language

Swift is a fast and efficient general-purpose programming language that provides real-time feedback and can be seamlessly incorporated into existing Objective-C code. This is why developers are able to write safer, more reliable code while saving time. It aims to be the best language that can be used for various purposes ranging from systems programming to mobile as well as desktop apps and scaling up to cloud services.

Below here, we list down the 10 best online resources to learn Swift language.

(The list is in no particular order)

#developers corner #free online resources to learn swift language #learn swift #learn swift free #learn swift online free #resources to learn swift #swift language #swift programming

Top Swift Development Companies | Top Swift Developers - TopDevelopers.co

A thoroughly researched list of top Swift developers with ratings & reviews to help find the best Swift development companies around the world.

#swift development service providers #best swift development companies #top swift development companies #swift development solutions #top swift developers #swift

Hire Dedicated Swift Developers

Want to create a native iOS application for your Startup?

Hire Dedicated Swift Developers for end-to-end services like development, migration, upgrade, testing, and support & maintenance. Trust HourlyDeveloper.io our Swift development team for iOS device apps that are high on performance and security.

Consult with experts:- https://bit.ly/2C5M6cz

#hire dedicated swift developers #swift developers #swift development company #swift development services #swift development #swift

Best Swift App Development Company

Hire an Exceptional Swift App Developer from Mobile App Development India. Maadi has a dedicated Swift App Development team that is superiorly talented and builds highly functional, cost-effective mobile apps with error-free coding.

Contact: https://www.mobile-app-development-india.com/swift-app-development/

#swift ios app development india #hire swift programmer india #swift ios development #apple swift app development #swift mobile app development #swift app development