Review Skeleton View for iOS Swift 5

Happy day guys, I hope you are happy and calm. In this tutorial, I'm gonna talk and show to you how Skeleton View works. Many apps nowdays are using it. It's like a common way to load something that's not finished yet. You can use it for loading text or image. And I think it's very good UX. Not jut bored loading spinner by default.

You can use Sekeleton View for UIImageView or UILabel. That's what I used for my app and I will show you later. Before I used Toast-Swift to handle loading. The code is pretty simple though but I still used it for loading stuff. I usually calls this code "self.view.makeToastActivity(.center)" to show loading spinner on center of screen. And After load API finished I hide the loading spinner using self.view.hideToastActivity(). Just like this.

And If you use UITableView, you need to implement SkeletonTableViewDataSource to give Skeleton an idea how to react spesific UITableViewCell through cell identifier. And If you don't it implement it, it's not working I have tried and that's confusing me a little while.

I will give a little bit code that explain well. I just give only important code that's we have to notice. As image example above. There are circle UIImageView that I made it Skeleton. It's acutally in UITableViewCell. So in my UIViewController I need to implement SkeletonTableViewDataSource delegate and return cell identifier.

And in UITableViewCell, first we need to initialize isSkeletonable variable to true. I did it in awakeFromNib() method. It's like viewDidLoad in UIViewController. Second I load API in layoutSubviews(). Because in there it could call many times when we reload UITableview using UITableView.reload().

In loadAPI I load API before load it. I show skeleton using setSkeletonHidden method to show and hide skeleton. After load API finish I hide skeleton. It's simple as like that. You can try to run your device and check it. My simulator I used it's used to be iPhone 11. My real device only iPhone 6s lol. I need to have iPhone SE to change it. I love compact smartphone. No need to have big screen. I just need good performence. That's all.

Thanks for visiting my simple blog. If you have any question, please comment below. I think I have busy project that's comming. I want to learn about flutter and I hope I can release it on Playstore and Appstore. And give you some good idea to use flutter. Learning never ends guys if you love it.

Popular posts from this blog

How to restart the app with flutter Android and iOS

Missing system image Android Studio solution

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android