Ever wanted to have your own custom loader view instead of iOS default activity indicator?
Is it difficult to create your own custom loader ???
No, it’s not. You can easily create custom loader using UIImageView animationImages property.You just need images using which you will create your own loader.
So here is the way to create loader :
- Initialize the object of UIImageView.
let customLoader = UIImageView(frame: frame)
- Add images which will be used for the animation using an array.
let imagesArray = [UIImage(named: "1.png")!, UIImage(named: "2.png")!, UIImage(named: "3.png")!, UIImage(named: "4.png")!, UIImage(named: "5.png")! ] customLoader.animationImages = imagesArray
- Set the duration of the single animation cycle.
customLoader.animationDuration = 0.5;
- Add customLoader as a subview to your view in which you want to show loader.
- Start the loader animation.
To stop loader you just need to write the following code:
- Stop the loader animation.
- Remove loader from super view.
Wow! You have created you own custom loader…