Skip to content

Instantly share code, notes, and snippets.

View aybekckaya's full-sized avatar
🏠
Working from home

Aybek Can Kaya aybekckaya

🏠
Working from home
View GitHub Profile
class ChronometerVC: UIViewController {
private var displayLink:DisplayLink?
private let lblCounter:UILabel = {
let lbl = UILabel()
lbl.font = UIFont(name: "Verdana", size: 28)
lbl.textAlignment = NSTextAlignment.center
lbl.textColor = UIColor.black
return lbl
}()
import UIKit
class ChronometerVC: UIViewController {
private var displayLink:DisplayLink?
private let pulsatingLayer:CAShapeLayer = {
let path = UIBezierPath(arcCenter: .zero, radius: 100, startAngle: 0, endAngle: CGFloat.pi * 2, clockwise: true)
let layer = CAShapeLayer()
layer.path = path.cgPath
layer.strokeColor = UIColor.clear.cgColor
// Animation values creator (1)
struct PulseConfiguration {
// static values
private var scaleChangeAmount:CGFloat = 0.015
private var maxScale:CGFloat = 1.5
private var minScale:CGFloat = 1
// dynamic Values
private var currentScale:CGFloat = 1
private var isExpanding:Bool = true
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
if window == nil {
window = UIWindow(frame: UIScreen.main.bounds)
}
let vc:LiveStreamVC = LiveStreamVC(nibName: "LiveStreamVC", bundle: nil)
let navigationController = UINavigationController(rootViewController: vc)
navigationController.isNavigationBarHidden = true
self.window?.rootViewController = navigationController
override func viewDidLoad() {
super.viewDidLoad()
let viewBox = UIView()
viewBox.frame = CGRect(x: 0, y: 0, width: 50, height: 50)
viewBox.backgroundColor = #colorLiteral(red: 0.7450980544, green: 0.1568627506, blue: 0.07450980693, alpha: 1)
self.view.addSubview(viewBox)
let path = createPath()
self.debugPath(path: path)
moveAlongPath(view: viewBox, path: path)
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }
self.window = UIWindow(windowScene: windowScene)
let vc = FirstViewController()
self.window?.rootViewController = vc
// MARK: Interactive Menu {Class}
class InteractiveMenu: UIView {
fileprivate let containerViewBottomMarginRate:CGFloat = 0.5 // 1
fileprivate let dampingValue:CGFloat = 1.5 // 2a
fileprivate let responseValue:CGFloat = 5.5 // 2b
fileprivate let viewBlurBackground:UIVisualEffectView = {
let blurEffect = UIBlurEffect(style: UIBlurEffect.Style.dark)
let blurView = UIVisualEffectView(effect: blurEffect)
blurView.translatesAutoresizingMaskIntoConstraints = true
// MARK: {Extension_Name}
extension {Class_Name} {
fileprivate func {Func_Name}() {
// It may be reachable from other extensions
// This function may use other fileprivate functions from other extensions
}
private func {Private_Func}()->{Returned_Value} {
// Do not use any function , but it may use a class variable inside it
// Oftenly returns a value
// MARK: Set Up
extension InteractiveMenu {
fileprivate func setUpUI() {
self.translatesAutoresizingMaskIntoConstraints = true //1
self.frame = CGRect(x: 0, y: 0, width: superview!.frame.size.width, height: superview!.frame.size.height)
self.addSubview(self.viewBlurBackground)
self.viewBlurBackground.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)
self.addSubview(self.containerView)
self.containerView.frame = CGRect(x: 0, y: self.frame.size.height - self.configuration.containerViewHeight, width: self.frame.size.width , height: self.totalHeightContainerView)
//MARK: InstantPanGesture
class InstantPanGesture : UIPanGestureRecognizer {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
super.touchesBegan(touches, with: event)
self.state = .began
}
}