Skip to content

Instantly share code, notes, and snippets.

@RustemAqtau
RustemAqtau / UIButton+extension.swift
Last active July 6, 2020 05:33
Extension UIButton
extension UIButton {
convenience init(title: String,
backgroundColor: UIColor,
font: UIFont?,
isShadow: Bool,
cornerRadius: CGFloat
titleColor: UIColor) {
self.init(type: .system) //инициализатор через type
@RustemAqtau
RustemAqtau / VCProvider.swift
Created March 8, 2020 15:58
Canvas Preview for ViewController
import SwiftUI
struct ViewControllerProvider: PreviewProvider {
static var previews: some View {
ContainerView().edgesIgnoringSafeArea(.all)
}
struct ContainerView:UIViewControllerRepresentable {
let viewController = ViewController()
@RustemAqtau
RustemAqtau / SceneDelegate.swift
Created March 8, 2020 16:19
SceneDelegate for Project without Storyboard
//1. Open info.plist
//2.Remove unnecesary storyboard settings from info.plist
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
@RustemAqtau
RustemAqtau / ButtonView.swift
Last active July 6, 2020 06:43
Form view extension(for combining two or more elements to one view)
import UIKit
class ButtonFormView: UIView {
init(label: UILabel, button: UIButton) {
super.init(frame: .zero)
self.translatesAutoresizingMaskIntoConstraints = false
label.translatesAutoresizingMaskIntoConstraints = false
button.translatesAutoresizingMaskIntoConstraints = false
@RustemAqtau
RustemAqtau / UIView+Extension.swift
Last active June 26, 2024 10:23
UIView Extension for configure constraints anchors programmatically
import UIKit
extension UIView {
func anchor(top: NSLayoutYAxisAnchor? = nil,
left: NSLayoutXAxisAnchor? = nil,
bottom: NSLayoutYAxisAnchor? = nil,
right: NSLayoutXAxisAnchor? = nil,
paddingTop: CGFloat = 0,
paddingLeft: CGFloat = 0,
paddingBottom: CGFloat = 0,
@RustemAqtau
RustemAqtau / UIFactory.swift
Created April 11, 2020 18:13
Factory for reuse Swift UIKIT
struct UIFactory {
struct Utility {
static func box(color: NSColor = .white, superview: NSView? = nil) -> NSBox {
let box = NSBox(frame: .zero)
box.boxType = .custom
box.borderColor = .clear
box.titlePosition = .noTitle
box.fillColor = color
@RustemAqtau
RustemAqtau / AppDelegate.swift
Last active July 2, 2020 09:39
AppDelegate without storyboard
class AppDelegate : UIResponder, UIApplicationDelegate {
var window : UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?)
-> Bool {
// if self.window is nil then set a new UIWindow object to self.window.
/* self.window = self.window ?? UIWindow()
// Set self.window's background color to red.
self.window!.backgroundColor = UIColor.red
@RustemAqtau
RustemAqtau / MainTabController.swift
Created July 2, 2020 15:16
TabController UIKIt
import UIKit
class MainTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
let listViewController = ListViewController()
let peopleViewController = PeopleViewController()
@RustemAqtau
RustemAqtau / TabBarController.swift
Created July 3, 2020 06:57
MainTabBarController Swift
import UIKit
class MainTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
extension UIFont {
static func avenir20() -> UIFont? {
return UIFont.init(name: "avenir", size: 20)
}
static func avenir26() -> UIFont? {
return UIFont.init(name: "avenir", size: 26)
}
}