Skip to content

Instantly share code, notes, and snippets.

View apple-avadhesh's full-sized avatar
🏠
Working from home

Avadhesh Sharma apple-avadhesh

🏠
Working from home
View GitHub Profile
@adamgit
adamgit / .gitignore
Last active July 25, 2024 19:57
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@flashspys
flashspys / Random.swift
Created September 20, 2014 09:48
simple swift random class
import UIKit
class Random {
class func randomInt() -> Int {
return Int(arc4random());
}
class func randomIntFrom(from: Int) -> Int {
@christopherhelf
christopherhelf / WKWebViewPlus.swift
Last active November 19, 2021 18:00
WKWebview Screenshots & Loading/Progress Notification
//
// WKWebViewPlus.swift
//
// Created by Christopher Helf on 19.09.15.
// Copyright © 2015 Christopher Helf. All rights reserved.
//
import Foundation
import UIKit
import WebKit
protocol SegueHandlerType {
associatedtype SegueIdentifier: RawRepresentable
}
// notice the cool use of where here to narrow down
// what could use these methods.
extension SegueHandlerType where Self: UIViewController,
SegueIdentifier.RawValue == String
{
import UIKit
class BlockBarButtonItem : UIBarButtonItem {
private var actionHandler: ((Void) -> Void)?
convenience init(image: UIImage?, actionHandler: ((Void) -> Void)?) {
self.init(image: image, style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
self.target = self
self.action = #selector(BlockBarButtonItem.barButtonItemPressed(_:))
@dfelber
dfelber / Color+Hex.swift
Last active August 6, 2021 10:05
Extension for UIColor and NSColor to initialize them with hexadecimal values like `0xcf0b69`
#if os(OSX)
import AppKit
typealias Color = NSColor
#elseif os(iOS) || os(tvOS)
import UIKit
typealias Color = UIColor
#endif
extension Color
@startupcode
startupcode / IoniconTitleUIButton.swift
Last active August 21, 2021 18:11
Swift - add ionicon icons in UIButton
//Swift - Using Iconicon icons in UIButton as Title.
//Ionicon.swift file needs to be added. It is attached here for reference
//Also you will require font file "ionicons.ttf"
//Calling the method
var btnTick = getButtonWithIconicon(CGRectMake(8, 12, 25, 25), title: String.ioniconWithCode("ion-checkmark-round")!, titleSize: UIFont.ioniconOfSize(25), titleColor: .greenColor())
func getButtonWithIconicon (coordinates: CGRect, title btnTitle: String, titleSize btnTitleSize: UIFont, titleColor btnTitleColor: UIColor) -> UIButton {
@Raghvendra7
Raghvendra7 / ScannerViewController.swift
Last active August 18, 2021 21:46
Scanning the barcode
import AVFoundation
import UIKit
class ScannerViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
var captureSession: AVCaptureSession!
var previewLayer: AVCaptureVideoPreviewLayer!
override func viewDidLoad() {
super.viewDidLoad()
@vincent-peng
vincent-peng / Data+HexEncodedString.swift
Last active November 26, 2023 14:28
Convert Data to hex string in Swift
// http://stackoverflow.com/a/40089462
extension Data {
func hexEncodedString() -> String {
return map { String(format: "%02hhx", $0) }.joined()
}
}
let timeLabel : UILabel = {
let label = UIlabel()
label.text = "hi"
return label
}()