How to Show Toast on iOS App with Swift

Showing Toast like image above for iOS app not as simple as Android. Now with AfriwanLib we can show Toast on iOS app easily with Swift language. This is simple step to show Toast like image above on AfriwanLib.

First step, you want to add pod 'AfriwanLib' similar to the following to your Podfile:

target 'MyApp' do
  pod 'AfriwanLib'

Run a pod install inside your terminal, then import AfriwanLib on your class.

import AfriwanLib

Now you can show Toast on your app with single line of code and you can add parameter you needed to modify your Toast. Below, the example code to show the Toast.

Simple toast:

toast(message: "your message", view: self.view)

Custom toast with some parameter:

toast(message: "This is Toast with parameter added:\ny (vertical position) and height", view: self.view, y: 145, height: 58)

Complete toast with modify all parameter:

toast(message: "Complete Toast with all parameter", view: view, duration: 5, textColor: UIColor.white, backgroundColor:, y: 179, height: 32, fontSize: 16)

Project example on my Github.

Posted on: July 8, 2019, by :
Translate »