Tutorial! Add android like toaster in iOS App with Toaster Pod.

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@iamankit·
0.000 HBD
Tutorial! Add android like toaster in iOS App with Toaster Pod.
Hello to all, this is @iamankit. I am iOS Developer for past 3 years. I have strong knowledge in objective c and swift language. Today i am going to show you how to add android like toaster in iOS App by adding Toaster pod in your project. So let's start the tutorial.
**First of all let me give you some brief about this tutorial.**

**What Will I Learn?**

- You will learn adding pod in iOS Project.
- You will learn adding toaster in your iOS Project.

 Requirements
- Mac
- Xcode
- Basic Knowledge of Swift Programming.

 Difficulty
- Basic

Nowadays we show many apps use toasters instead of alerts to users for showing information. Toasters are similar to alert boxes with advance features and good design. There are two ways to for adding toaster in our project, first one is design our own toaster and second one is use a library to reduce our time and effort. In today's tutorial i am going to use [devxoul/Toaster Library.](https://github.com/devxoul/Toaster) So, let's add a toaster in our app.

- First of all open your Xcode and create a single view app.
![Screen Shot 2018-01-14 at 9.22.28 AM.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515903186/vw5leku1pkjnhuvmpdbo.png)
- Now go to your project directory from terminal and write pod init and press enter. This command will create a pod file in your project directory. Now open the pod file in text editor and add pod 'Toaster' to the Podfile. Save the file and close it.
![Screen Shot 2018-01-14 at 9.41.26 AM.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515903387/duinqpk8thfatodh1iss.png)
- After saving the Podfile go to your terminal again and go to your project directory. Now type pod install in your terminal and press enter. This command will install pod dependencies in your project.
![Screen Shot 2018-01-14 at 9.49.21 AM.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515903640/z4bvrqliqfh0f035i8ih.png)
- Our half of work is done and now we need to implement toaster in our project. To add toaster go to your ViewController.Swift file and import toaster class by writing import Toaster under import UIKIT.
- Now we need to present our toaster. To show toaster create a function in your ViewController.Swift file and call that function in viewDidLoad() method. Like this -
![Screen Shot 2018-01-14 at 10.05.19 AM.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515904766/m40g9y2wi0fhcssmoakc.png)

- Now run your app. Wow! a nice toaster just popped on your view controller. The method we use is show toaster as your view load. There are also other classes too for your use like if you want to show toaster with some delay then you have to use "Toast(text: "Hello, world!", delay: Delay.long)". 
- If you want to add delay in showing of toaster and also wants that toaster hides after long time then you can use this "Toast(text: "Hello, world!", delay: Delay.short, duration: Delay.long)".
- If you want to remove toaster immediately then you have to use ".cancel()" method.
- Try another classes of toaster too in your project. I teach you all the basic info about Toaster pod now it's your turn to explore the pod and learn all about the Toaster Pod. If you stuck at somewhere then i am always here to help you. I also add Toaster Pod Github Repository link with tutorial for your better understanding. On the Github Page of pod you will find almost every information regarding the pod.

Thanks for reading this tutorial. Stay tuned for next tutorial.

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@iamankit/tutorial-add-android-like-toaster-in-ios-app-with-toaster-pod">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍 , , , , , , , , ,