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 / 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 / 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 / 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)
}
}
@bluebanboom
bluebanboom / stringFromTimeInterval
Created June 12, 2012 14:54
Create NSString from NSTimeInterval with format HH:MM::SS
- (NSString *)stringFromTimeInterval:(NSTimeInterval)interval
{
NSInteger ti = (NSInteger)interval;
NSInteger seconds = ti % 60;
NSInteger minutes = (ti / 60) % 60;
NSInteger hours = (ti / 3600);
NSString *time = nil;
if (hours > 0) {
time = [NSString stringWithFormat:@"%02i:%02i:%02i", hours, minutes, seconds];
}