Skip to content

Instantly share code, notes, and snippets.

View karthikAdaptavant's full-sized avatar
🎯
Focusing

Karthik samy karthikAdaptavant

🎯
Focusing
  • 17:11 (UTC +05:30)
View GitHub Profile
@cbess
cbess / xcode-pods.sh
Created June 28, 2013 14:55
Xcode "Run Script" cocoapods phase
echo Process pods
if [ ! -e /usr/bin/pod ] ; then
echo Installing cocoapods...
gem install cocoapods
fi
pod update
@shaps80
shaps80 / UINavigationController-Gesture.m
Last active September 23, 2020 08:35
Custom UINavigationController back button item, without losing iOS 7 swipe back gesture.
navigationController
.interactivePopGestureRecognizer
.delegate = (id<UIGestureRecognizerDelegate>)navigationController;
@siberianisaev
siberianisaev / UINavigationBar+Height.swift
Last active October 30, 2019 07:57
Change height of UINavigationBar
import Foundation
private var AssociatedObjectHandle: UInt8 = 0
extension UINavigationBar {
var height: CGFloat {
get {
if let h = objc_getAssociatedObject(self, &AssociatedObjectHandle) as? CGFloat {
@yonat
yonat / Badge.swift
Last active December 22, 2022 09:40
Rounded UILabel and UIButton, Badged UIBarButtonItem
//
// Badge.swift
// Extensions for Rounded UILabel and UIButton, Badged UIBarButtonItem.
//
// Usage:
// let label = UILabel(badgeText: "Rounded Label");
// let button = UIButton(type: .System); button.rounded = true
// let barButton = UIBarButtonItem(badge: "42", title: "How Many Roads", target: self, action: "answer")
//
// Created by Yonat Sharon on 06.04.2015.
@nazywamsiepawel
nazywamsiepawel / UINavigationBarWithSubtitle.swift
Last active July 20, 2023 11:58
UINavigationBar with subtitle / swift
func setTitle(title:String, subtitle:String) -> UIView {
let titleLabel = UILabel(frame: CGRect(x:0, y:-5, width:0, height:0))
titleLabel.backgroundColor = UIColor.clear
titleLabel.textColor = UIColor.gray
titleLabel.font = UIFont.boldSystemFont(ofSize: 17)
titleLabel.text = title
titleLabel.sizeToFit()
@nazywamsiepawel
nazywamsiepawel / NSURL+params.swift
Created September 3, 2015 12:18
Extract query parameters from NSURL
extension NSURL {
func queryParams() -> Dictionary<String, String> {
var params = Dictionary<String, String>()
if let queryParams = self.query?.componentsSeparatedByString("&") {
for param in queryParams {
var parts = param.componentsSeparatedByString("=")
params[parts[0]] = parts[1]
}
}
@bishalg
bishalg / AppInfo.swift
Last active November 3, 2017 16:51
AppInfo Swift - Util to get app infos like build / version number etc
//
// AppInfo.swift
// This is an Util to get app infos like build / version number etc
// Swift 3.0
// Xcode 8.0
//
import Foundation
import AVFoundation
@nazywamsiepawel
nazywamsiepawel / gist:fb6e059f092776fb62bada8e35b2f39c
Created April 20, 2016 20:46
Custom back button / chevron + gesture recognizer
self.navigationItem.leftBarButtonItem =
UIBarButtonItem(image:UIImage(named:"chevron_left"), style:.Plain, target:self, action:"backButtonPressed:");
self.navigationController!.interactivePopGestureRecognizer!.delegate = self;
@benbahrenburg
benbahrenburg / BaseController.swift
Last active October 4, 2018 16:57
Adding Consistent Back Button to view
import UIKit
class BaseViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let backTitle = NSLocalizedString("Back", comment: "Back button label")
self.addBackbutton(backTitle)
protocol JSONInitable {
init(data: JSON)
}
extension JSON {
func to<T where T: JSONInitable>(type: T.Type) -> [T] {
return self.arrayValue.map {
return T(data: $0)
}
}