-
Notifications
You must be signed in to change notification settings - Fork 1
/
UIViewController+Extension.swift
35 lines (31 loc) · 1.36 KB
/
UIViewController+Extension.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// UIViewController+Extension.swift
//
// Copyright © 2023 Zendesk. All rights reserved.
//
import Foundation
import UIKit
extension UIViewController {
func showToast(message: String, seconds: Double) {
let alert = UIAlertController(title: nil, message: message,
preferredStyle: .actionSheet)
alert.view.layer.cornerRadius = 15
present(alert, animated: true)
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
alert.dismiss(animated: true)
}
}
func insertGradientLayer(_ gradientLayer: CAGradientLayer, backgroundView: UIView) {
let backgroundColor = UIColor(named: "backgroundColor")
gradientLayer.frame = self.view.bounds
gradientLayer.colors = [UIColor.white.cgColor, backgroundColor!.cgColor]
backgroundView.layer.insertSublayer(gradientLayer, at: 0)
}
func makeAlert(title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
let okButton = UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil)
okButton.setValue(UIColor(named: "cardButtonColor"), forKey: "titleTextColor")
alert.addAction(okButton)
self.present(alert, animated: true, completion: nil)
}
}