Skip to content

Instantly share code, notes, and snippets.

import UIKit
class MenuViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .purple
}
}
import UIKit
import SWRevealViewController
class FrontViewController: UIViewController {
/// overlay view
lazy var overlayView : UIView = {
let view = UIView()
view.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.6)
return view
import UIKit
import SWRevealViewController
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
/// swRevealContainer
var swContainer : SWRevealViewController?
import UIKit
import SWRevealViewController
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
/// swRevealContainer
var swContainer : SWRevealViewController?
//
// RefreshControl.swift
// BusinessDirectory
//
// Created by mukesh awal on 1/22/20.
// Copyright © 2020. All rights reserved.
//
/******************************************************************
-uses RxSwift and RxCocoa
// call this function after your desired task after refreshing is completed
func endRefreshing(){
circleLayer.removeAllAnimations()
UIView.animate(withDuration: 0.35, animations: {[weak self] in
self?.containerScrollView?.contentInset.top = 0.0
}, completion: {[weak self] _ in
self?.refreshingStatus = false
})
}
//MARK: - common init
private func commonInit(){
shapeLayer.fillColor = setFillColor.cgColor
shapeLayer.actions = ["path" : NSNull(), "position" : NSNull(), "bounds" : NSNull()]
layer.addSublayer(shapeLayer)
shapeLayer.masksToBounds = true
circleLayer.lineWidth = 4
circleLayer.strokeColor = setRefreshCircleColor.cgColor
circleLayer.fillColor = UIColor.clear.cgColor
override func didMoveToSuperview() {
super.didMoveToSuperview()
addObserver(.contentOffset)
addObserver(.panGesture)
}
//MARK: - observers
/// Add scroll view content y offset and scroll view panGesture observers
/// - Parameter observer: RefreshControl.Observer type
private func addObserver(_ observer : Observer){
//
// RefreshControl.swift
//
// Created by mukesh awal on 1/22/20.
// Copyright © 2020. All rights reserved.
//
/******************************************************************
-uses RxSwift and RxCocoa
-add instance of this class to background of your scroll view
****************************** points ***********************************