Skip to content

Instantly share code, notes, and snippets.

View Leonif's full-sized avatar

LEONID NIFANTIJEV Leonif

  • iOS Developer
  • Kyiv
View GitHub Profile
//
// Created by Leonid Nifantyev on 2019-05-26.
// Copyright (c) 2019 Nifantyev. All rights reserved.
//
import UIKit
import SwiftyAttributes
typealias EventHandler<T> = ((T) -> Void)
func showActionSheet(actionsTitles: [String], currentIndex: Int) {
let optionMenu = UIAlertController(title: "Select League season", message: .none, preferredStyle: .actionSheet)
optionMenu.view.tintColor = .white
for ( index, title ) in actionsTitles.enumerated() {
let action = UIAlertAction(title: title, style: .default) { [weak self] _ in
self?.selectAction(index: index)
}
action.setValue(UIColor.white, forKey: "titleTextColor")
optionMenu.addAction(action)
@Leonif
Leonif / GradientButton
Created April 6, 2019 13:26
Now you can adв gradient on button, which is updated with buttonautolayout
// MARK: - custom class
class GradientButton: UIButton {
override class var layerClass: Swift.AnyClass {
return CAGradientLayer.self
}
}
// MARK: - usage example of Gradient Button
extension Array where Element: Equatable {
func calculateNextIndex(for currentIndex: Int) -> Int {
let newIndex = currentIndex < self.count - 1 ? currentIndex + 1 : 0
return newIndex
}
func fetchNextElement(after currentIndex: Int) -> Element {
let nextIndex = self.calculateNextIndex(for: currentIndex)
return self[nextIndex]
}
//
// EmailHelper.swift
// NurKZ
//
// Created by Nifantyev on 1/28/19.
// Copyright © 2019 Genesis. All rights reserved.
//
import MessageUI
//
// UIView+Tap.swift
// Tele2
//
// Created by l.nifantyev on 10/11/18.
// Copyright © 2018 Tele2. All rights reserved.
//
import Foundation
import UIKit
class DashBoardView: LoadableView {}
@Leonif
Leonif / Example.swift
Last active December 15, 2018 17:00
ImageView which can calculate own content and adjusted like UIlabel
func config(imgUrl: String, estimatedSize: CGSize?, description: NSAttributedString?) {
postImageView.estimatedSize = estimatedSize
postImageView.loadImg(fromUrl: imgUrl)
}
extension UISearchBar {
var textField: UITextField {
guard let tf = (value(forKey: "searchField") as? UITextField) else { fatalError() }
return tf
}
func addToolBar() {
//Add done button to numeric pad keyboard
let toolbarDone = UIToolbar.init()
toolbarDone.sizeToFit()
//
// UILinkedLabel.swift
// Tele2
//
// Created by l.nifantyev on 10/10/18.
// Copyright © 2018 Tele2. All rights reserved.
//
import Foundation
import UIKit