Skip to content

Instantly share code, notes, and snippets.

View naveedmcs's full-sized avatar
👨‍💻
Nothing is interesting if You are not interested.

Muhammad Naveed naveedmcs

👨‍💻
Nothing is interesting if You are not interested.
View GitHub Profile
@naveedmcs
naveedmcs / GroupSequance.swift
Created November 6, 2019 05:43
GroupSequance
/*Grouping sequences
Dictionaries have a marvelous initializer called Dictionary(grouping:), and its job is to convert a sequence into a dictionary based on any grouping you want.
As an example, here’s an array of popular Swift conferences:*/
let conferences = ["AltConf", "App Builders", "NSSpain"]
//We could group that into a dictionary, using the first letter of each conference as the key and the conference names stored as an array:
let alphabetical = Dictionary(grouping: conferences) { $0.first! }
@naveedmcs
naveedmcs / gist:ba537060dc40e5a39472a8c04c0ab51b
Created October 24, 2019 06:49 — forked from snikch/gist:3661188
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@naveedmcs
naveedmcs / topMostViewController.swift
Created October 24, 2019 06:40 — forked from db0company/topMostViewController.swift
Get the top most viewController anywhere in the app (typically from the appDelegate). Get the current visible viewController.
extension UIViewController {
func topMostViewController() -> UIViewController {
if self.presentedViewController == nil {
return self
}
if let navigation = self.presentedViewController as? UINavigationController {
return navigation.visibleViewController.topMostViewController()
}
if let tab = self.presentedViewController as? UITabBarController {
if let selectedTab = tab.selectedViewController {
@naveedmcs
naveedmcs / UserDefaultLoginManager.swift
Created October 14, 2019 13:05
UserDefaultLoginManager
import UIKit
import Foundation
enum LoginType: String {
case email
case facebook
case google
case instagaram
case guest
}
@naveedmcs
naveedmcs / statusBarView.swift
Created October 13, 2019 09:47
statusBarView
xtension UIApplication {
class var statusBarBackgroundColor: UIColor? {
get {
return statusBarUIView?.backgroundColor
} set {
statusBarUIView?.backgroundColor = newValue
}
}
@naveedmcs
naveedmcs / statusbar-color-change.md
Created October 3, 2019 06:49 — forked from WrathChaos/statusbar-color-change.md
iOS 13 and Below How to change Status Bar Color?
if #available(iOS 13.0, *) {
    let app = UIApplication.shared
    let statusBarHeight: CGFloat = app.statusBarFrame.size.height
    
    let statusbarView = UIView()
    statusbarView.backgroundColor = UIColor.red
    view.addSubview(statusbarView)
  
 statusbarView.translatesAutoresizingMaskIntoConstraints = false
@naveedmcs
naveedmcs / PageViewController.swift
Created September 20, 2019 10:41 — forked from miguelfermin/PageViewController.swift
Demonstrates how to add a UIPageViewController to a UIViewController
//
// ViewController.swift
// PageViewController
//
// Created by Miguel Fermin on 5/8/17.
// Copyright © 2017 MAF Software LLC. All rights reserved.
//
import UIKit
@naveedmcs
naveedmcs / XLPagerTabStrip.swift
Created September 19, 2019 13:04 — forked from iAmrSalman/XLPagerTabStrip.swift
[XLPagerTabStrip] #swift #XLPagerTabStrip
import UIKit
import XLPagerTabStrip
class ProfileTabsVC: ButtonBarPagerTabStripViewController {
//MARK: - Life Cycle
override func viewDidLoad() {
setupPager()
super.viewDidLoad()
@naveedmcs
naveedmcs / tableViewActivityIndicator.swift
Created September 19, 2019 12:54 — forked from iAmrSalman/tableViewActivityIndicator.swift
[tableViewActivityIndicator] Add a ActivityIndicator to the bottom of UITableView while loading #swift3 #tableview #paging
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let lastSectionIndex = tableView.numberOfSections - 1
let lastRowIndex = tableView.numberOfRows(inSection: lastSectionIndex) - 1
if indexPath.section == lastSectionIndex && indexPath.row == lastRowIndex {
// print("this is the last cell")
let spinner = UIActivityIndicatorView(activityIndicatorStyle: .gray)
spinner.startAnimating()
spinner.frame = CGRect(x: CGFloat(0), y: CGFloat(0), width: tableView.bounds.width, height: CGFloat(44))
self.tableView.tableFooterView = spinner
import Foundation
class BaseAPIResponse : Codable {
let success : Bool?
let message : String?
// let data : [Product]?
let errors : [String:String]?