Splash Screen With Custom Dots FrameWork

Amirhossein Hashemi
4 min readNov 29, 2017

--

Using splash screens getting more and more popular in applications specially in the first page of applications to show the user how application works. They usually have dots at their bottom. I recently created splash screen with custom dots. You can give your images as a dots to it. By using this frame work you can just put your view inside storyboard of your application and give it some photos, and then have your custom splash screen. You can find out about implementation of this framework in your application at the end of this article..

You can download the framwork from this address and use it in your code:

At first I am going to explain some notice and then I can find the way that this framework can get implemented in the storyboard.

  1. To make a custom view may be the common approach is to make it all programmatically, But I decided to do this custom view by xib file for views. I think it makes it easier. Just there is some small notice should be considered :

“Nib files play an important role in the creation of applications in OS X and iOS. With nib files, you create and manipulate your user interfaces graphically, using Xcode, instead of programmatically. “

From:https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html

1. By the power of Nib it is possible to work with views as you work in storyboard, just you need to load your xib files in init method of your class. If you are going to make it framework it is necessary to load it into the framework bundle based on a class defined in the framework.

Wait a moment, what is a bundle, what that means?

Bundle

A representation of the code and resources stored in a bundle directory on disk.

By using a bundle object, you can access a bundle’s resources without knowing the structure of the bundle.

The main bundle represents the bundle directory that contains the currently executing code. So for an app, the main bundle object gives you access to the resources that shipped with your app.

You can always create bundle objects from a known URL or path, but other methods make it easier to access bundles your app is already using. For example, if you link to a framework, you can use the init(for:)method to locate the framework bundle based on a class defined in that framework.

From : https://developer.apple.com/documentation/foundation/bundle

So the reason is that main bundle does not access the xib files. In other words the main bundle does not have these xib files inside itself. If you create your view programmatically you would not need to do these things.

2. It is important to know about the order of executing method while the application gets launched. Considering this sequence will help a lot. Imagine we have a view controller with viewDidLoad method. Your application has a xib file which contains collection view. Consider the xib file with init method which is kind of setup for the view. Also, collection view methods are in xib class file owner. Which method do you think will get executed first.

1.First init method of xib class file owner get executed.

2.Then viewDidLoad in view controller.

3.And then collection view methods in xib class file owner.

So that like my case, which I need some information from delegate (Like images dor dots and slides) I have to get all information of my delegate inside my collection view method not in init method.

Method setup is belong to init method which is located in xib class. Also collection view methods are inside xib class. This photo shows the sequence of executing methods by red arrows.

Implementation

  1. After creating your projects which you want to use splash screen on it, you can drag and drop the framework to you project.

2. In general->Embaded Bineries the framework should be added.

3. Create one view in your view controller in Storyboard.The name of the class for this view should be Slides.

4. In the view controller class, the CustomSplashScreen framework should be imported. So that you have accessibility to all public class and function inside the framework. The view controller needs to conform to CustomPageControlDelegate protocol. You can do it in one extension which is more organized.

There are three method that you would be forced to create. In these three method you will give the framework your custom dots and slides which you want to be shown inside the view. Also you need to give it the number of images.

5. Bring your images to the Assets.And Create your images inside the methods to give the methods arrays of images.

6. Inside the viewDidLoad, the outlet to the view that has two delegate properties, should get referenced to self. (ViewController class). And the last step is overriding the viewDidAppear and setup the splash screen by setup method.

--

--