Skip to content

Instantly share code, notes, and snippets.

View IlijaMihajlovic's full-sized avatar

IlijaMihajlovic IlijaMihajlovic

View GitHub Profile
@IlijaMihajlovic
IlijaMihajlovic / RootViewController in SceneDelegate.swift
Created September 13, 2022 10:45
Set ViewController in SceneDelegate Programmatically
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
let navController = UINavigationController(rootViewController: FirstScreen())
window?.rootViewController = navController
window?.makeKeyAndVisible()
// MARK: - Properties
lazy var buttonTapped: UIButton = {
let button = UIButton(type: .system)
button.setImage(UIImage(named: "more")?.withRenderingMode(.alwaysTemplate), for: .normal)
button.frame = CGRect(x: 0, y: 0, width: 45, height: 45)
button.addTarget(self, action: #selector(handleButtonTapped), for: .touchUpInside)
return button
}()
fileprivate func addViewToSubView() {
[mainView, detailView, descriptionTextView].forEach{view.addSubview($0)}
}
@IlijaMihajlovic
IlijaMihajlovic / AutoLayoutAnchorExtension.swift
Created September 13, 2022 12:02
Auto Layout Anchor Extension Programmatically
import UIKit
//MARK: - Auto Layout Anchor Extension
extension UIView {
func anchor(top: NSLayoutYAxisAnchor?, bottom: NSLayoutYAxisAnchor?, leading: NSLayoutXAxisAnchor?, trailing: NSLayoutXAxisAnchor?, padding: UIEdgeInsets = .zero, size: CGSize = .zero) {
if let top = top {