Skip to content

Instantly share code, notes, and snippets.

@furydeveloper
furydeveloper / MainViewController.swift
Created August 20, 2019 02:48
MainViewController.swift
extension MainViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return personData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: MainTableViewCell.identifier, for: indexPath) as! MainTableViewCell
cell.personImage.image = personData[indexPath.row].personImage ?? UIImage(named: "default")
cell.personName.text = personData[indexPath.row].personName ?? ""
@furydeveloper
furydeveloper / LoadingHUD.swift
Created August 20, 2019 02:55
LoadingHUD.swift
private static let sharedInstance = LoadingHUD()
if let window = UIApplication.shared.keyWindow {
window.addSubview(backgroundView)
window.addSubview(popupView)
window.addSubview(loadingLabel)
}
@furydeveloper
furydeveloper / LoadingHUD.swift
Created August 20, 2019 02:56
LoadingHUD.swift
class func show() {
let backgroundView = UIView(frame: CGRect.init(x: 0, y: 0, width: 100, height: 100))
let popupView = UIImageView(frame: CGRect.init(x: 0, y: 0, width: 100, height: 100))
popupView.animationImages = LoadingHUD.getAnimationImageArray()
popupView.animationDuration = 0.8
popupView.animationRepeatCount = 0
let loadingLabel = UILabel(frame: CGRect.init(x: 0, y: 0, width: 100, height: 100))
loadingLabel.text = "Loading ..."
@furydeveloper
furydeveloper / LoadingHUD.swift
Created August 20, 2019 02:57
LoadingHUD.swift
private class func getAnimationImageArray() -> [UIImage] {
var animationArray: [UIImage] = []
animationArray.append(UIImage(named: "frame_loading_01")!)
animationArray.append(UIImage(named: "frame_loading_02")!)
animationArray.append(UIImage(named: "frame_loading_03")!)
animationArray.append(UIImage(named: "frame_loading_04")!)
animationArray.append(UIImage(named: "frame_loading_05")!)
animationArray.append(UIImage(named: "frame_loading_06")!)
animationArray.append(UIImage(named: "frame_loading_07")!)
animationArray.append(UIImage(named: "frame_loading_08")!)
@furydeveloper
furydeveloper / LoadingHUD.swift
Created August 20, 2019 02:58
LoadingHUD.swift
class func hide() {
if let popupView = sharedInstance.popupView,
let loadingLabel = sharedInstance.loadingLabel,
let backgroundView = sharedInstance.backgroundView {
popupView.stopAnimating()
backgroundView.removeFromSuperview()
popupView.removeFromSuperview()
loadingLabel.removeFromSuperview()
}
}
@furydeveloper
furydeveloper / ViewController.swift
Created August 20, 2019 02:59
ViewController.swift
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: self, action: #selector(taped(_:)))
self.view.gestureRecognizers = [tap]
}
@objc func taped(_ sender: UITapGestureRecognizer) {
LoadingHUD.show()
@furydeveloper
furydeveloper / ViewController.swift
Created August 20, 2019 03:05
ViewController.swift
import UIKit
import NMapsMap
class ViewController: UIViewController, NMFMapViewDelegate {
var authState: NMFAuthState!
override func viewDidLoad() {
super.viewDidLoad()
@furydeveloper
furydeveloper / AppDelegate.swift
Created August 21, 2019 01:53
AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var deviceToken: Data? = nil
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
@furydeveloper
furydeveloper / LoginViewController.swift
Last active August 21, 2019 02:15
LoginViewController.swift
import UIKit
class LoginViewController: UIViewController {
private let loginButton: KOLoginButton = {
let button = KOLoginButton()
button.addTarget(self, action: #selector(touchUpLoginButton(_:)), for: .touchUpInside)
button.translatesAutoresizingMaskIntoConstraints = false
return button
}()
@furydeveloper
furydeveloper / MainViewController.swift
Created August 21, 2019 02:16
MainViewController.swift
import UIKit
class MainViewController: UIViewController {
let emailLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()