Skip to content

Instantly share code, notes, and snippets.

View grifas's full-sized avatar
🇫🇷
iOS Developer

Aurélien grifas

🇫🇷
iOS Developer
  • Lyon
View GitHub Profile
@grifas
grifas / socialNetworksDeepLinks.swift
Created November 30, 2017 16:08
Social Networks Deep Links
@grifas
grifas / AddJsonFileToTestBundle.txt
Created December 18, 2017 17:24
Add json file to test bundle
Build Phases -> Add Build Phase -> Copy Bundle Resources
Add json file there
@grifas
grifas / HMAC-SHA1-BASE64-SIGNATURE.swift
Last active January 11, 2018 15:07
String Extension to get based 64 signature to sign google api urls in swift 3
// String Extension to get based 64 signature to sign google api urls in Swift 3
// FROM https://stackoverflow.com/a/20300625/5965126
extension String {
func signatureBase64(key: String) -> String? {
if let signature = self.data(using: .utf8) as NSData?, let signingKey = self.decodeURLBase64String(string: key) {
if let digest = self.hmacSha1(data: signature, key: signingKey) {
return self.encodeURLBase64Data(data: digest)
}
}
@grifas
grifas / controller.swift
Last active January 11, 2018 15:07
Pushed View Controller with a transparent navigation bar
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
initNavigationBar()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
UIApplication.shared.statusBarStyle = .lightContent
@grifas
grifas / setLeftTitleView.swift
Last active March 2, 2018 10:43
iOS - Set a left title view in navigation bar
override func viewDidLoad() {
super.viewDidLoad()
// This keep the back button after setting the left title view
navigationItem.leftItemsSupplementBackButton = true
}
func setLeftTitleView() {
let titleLabel = UILabel()
@grifas
grifas / ScrollViewSwipeGestureRequireToFail.swift
Last active August 3, 2018 08:44
SwipeGesture in scrollView: require to fail.
class ChildViewController: UIViewController {
func addSwipeGesture() {
let leftGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(swipe))
let rightGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(swipe))
leftGestureRecognizer.delegate = self
rightGestureRecognizer.delegate = self
leftGestureRecognizer.direction = UISwipeGestureRecognizerDirection.left
rightGestureRecognizer.direction = UISwipeGestureRecognizerDirection.right
@grifas
grifas / SelfSizingAccessoryViewCell.swift
Last active September 17, 2018 15:48
UITableViewCell with a self sizing accessory view
class MyCell: UITableViewCell {
init() {
// Initialize...
accessoryView = UIView()
accessoryView?.translatesAutoresizingMaskIntoConstraints = false
addSubview(accessoryView!)
@grifas
grifas / TopIconButton.swift
Created October 1, 2018 16:19
A button with an icon on top
import Foundation
class TopIconButton: UIButton {
var color: UIColor = Color.Green
private init(with color: UIColor) {
self.color = color
super.init(frame: .zero)