Skip to content

Instantly share code, notes, and snippets.

View ArtiomKha's full-sized avatar

Artiom ArtiomKha

View GitHub Profile
import UIKit
struct Colors {
static let background = #colorLiteral(red: 0.657153666, green: 0.8692060113, blue: 0.6173200011, alpha: 1)
static let draggedBackground = #colorLiteral(red: 0.462745098, green: 0.7843137255, blue: 0.5764705882, alpha: 1)
static let tint = #colorLiteral(red: 0.1019607843, green: 0.4588235294, blue: 0.6235294118, alpha: 1)
}
protocol SlideToActionButtonDelegate: AnyObject {
func didFinish()
import UIKit
protocol DropDownButtonDelegate: AnyObject {
func didSelect(_ index: Int)
}
class DropDownButton: UIView {
let button: UIButton = {
let button = UIButton()
@ArtiomKha
ArtiomKha / GenericViewController.swift
Created February 14, 2023 07:28
Source code for the Medium article about separating view and view controller
import UIKit
class GenericViewController<T: UIView>: UIViewController {
public var rootView: T { return view as! T }
override open func loadView() {
self.view = T()
}
@ArtiomKha
ArtiomKha / AttributedString.swift
Created February 10, 2023 10:42
Gist with source code for the Medium article about NSAttributedString
import UIKit
struct MovieInfo {
let title: String
let description: String
let cast: [ActorInfo]
}
struct ActorInfo {
@ArtiomKha
ArtiomKha / RadioButton.swift
Last active November 9, 2023 02:38
Gist for Medium article about radio button
import UIKit
class RadioButton: UIControl {
var unselectedBackgroundColor: UIColor = .white {
didSet {
contentView.backgroundColor = unselectedBackgroundColor
}
}
import UIKit
class Checkbox: UIControl {
let checkedView: UIImageView = {
let view = UIImageView()
view.translatesAutoresizingMaskIntoConstraints = false
view.isHidden = true
view.image = UIImage(systemName: "checkmark")?.withRenderingMode(.alwaysTemplate)
view.tintColor = .white
@ArtiomKha
ArtiomKha / StyledButton.swift
Last active January 21, 2023 20:31
Gist for Medium article about custom button styles
import UIKit
struct Colors {
static let primary: UIColor = #colorLiteral(red: 0.3215686275, green: 0.7176470588, blue: 0.5333333333, alpha: 1) // #52B788
static let white: UIColor = .white
static let lightGray: UIColor = #colorLiteral(red: 0.9254901961, green: 0.9254901961, blue: 0.9254901961, alpha: 1) // #ECECEC
static let darkGray: UIColor = #colorLiteral(red: 0.6352941176, green: 0.6352941176, blue: 0.6352941176, alpha: 1) // #A2A2A2
}