This tutorial illustrates to How to implement a toast message in iOS using swift with very simple interface. Swift is a new programming language for iOS and OSX project if you don’t have any information related to swift programming language then please first refer our previous blog about overview of Swift Application Development.
Follow the below mentioned steps to implement toast message using Swift programming language in iOS:
Step 1 Download JLToast & Add in Project
First download the attached sample code, then from that code copy JLToast folder and put this folder in your project and then drag and drop it in your xcode project.
Step 2 JLToast Methods
Now to display toast message; call below mentioned method. You can specify the delay to display and can specify the duration of toast message as shown in below example.
JLToast.makeText("Simple Toast Message").show()
JLToast.makeText("Toast Message With Specified Duration.", duration: 3).show()
JLToast.makeText("Toast Message With Specified Duration And Delay.", delay: 1, duration: 5) ).show()
You can also set the value of duration and delay using the variable from JLToastDelay structure.
JLToast.makeText("Toast Message With Specified Duration And Delay.", delay: JLToastDelay.ShortDelay, duration: JLToastDelay.LongDelay) ).show()
Find the sample program mentioned in step1 in below link.
You will get final Output:
I hope you found this blog helpful while Implementing Toast Message in iOS using Swift.