This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//call the method | |
let convertedDateString = self.dateFromString("2019-05-20", fromFormat: "yyyy-MM-dd", toFormat: "dd-MM-yyyy") | |
print(convertedDateString ?? "Failed to convert date") | |
func dateFromString(_ dateString:String, fromFormat:String, toFormat: String) -> String? { | |
let dateFormatter = DateFormatter() | |
dateFormatter.dateFormat = fromFormat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Open new Terminal tabs from the command line | |
# | |
# Author: Justin Hileman (http://justinhileman.com) | |
# | |
# Installation: | |
# Add the following function to your `.bashrc` or `.bash_profile`, | |
# or save it somewhere (e.g. `~/.tab.bash`) and source it in `.bashrc` | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
let cell: CustomCollectionViewCell = collectionView.dequeueReusableCell(forIndexPath: indexPath) | |
... | |
//add shadow | |
cell.applyShadow() | |
.... | |
return cell | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
// MARK: - SafeArea Extensions | |
extension UIView { | |
var safeTopAnchor: NSLayoutYAxisAnchor { | |
if #available(iOS 11.0, *) { | |
return self.safeAreaLayoutGuide.topAnchor | |
} | |
return self.topAnchor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol LoaderViewType: UIView { | |
func startAnimating() | |
func stopAnimating() | |
} | |
class LoaderButton: UIButton, LoaderViewType { | |
fileprivate let activityLoader: UIActivityIndicatorView = { | |
let indicator = UIActivityIndicatorView(style: .gray) | |
indicator.translatesAutoresizingMaskIntoConstraints = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ThrottledSearchController.swift | |
// Created by Daniele Margutti on 10/19/2017 | |
// Updated by RAFAT TOUQIR RAFSUN. | |
import UIKit | |
class ThrottledSearchController: UISearchController{ | |
// Mark this property as lazy to defer initialization until | |
// the searchBar property is called. | |
private lazy var customSearchBar = ThrottledSearchBar() |
OlderNewer