Skip to content

Instantly share code, notes, and snippets.

View Achyut-Sagar's full-sized avatar

Sagar Joshi Achyut-Sagar

View GitHub Profile
@Achyut-Sagar
Achyut-Sagar / GenericPropertyInitializer.swift
Created February 3, 2021 06:58
Initilizes a property using self executing clousure.
/// Generic Property Intializer
/// - Parameters:
/// - value: Instance of Class
/// - closure: closure of property setters
/// - Returns: instance of passed class
static func configure<T>(_ value: T, using closure: (inout T) throws -> Void) rethrows -> T {
var value = value
try closure(&value)
return value
}
import MobileCoreServices
import Foundation
import UIKit
struct GeneralUtility{
public static var appDelegate : AppDelegate{
get{
return UIApplication.shared.delegate as! AppDelegate
}
@Achyut-Sagar
Achyut-Sagar / OffsetLabel.swift
Created January 4, 2020 12:57
Subclass of UIlabel that implements offset.
import UIKit
class OffsetLabel: UILabel {
@IBInspectable var inset:CGSize = CGSize(width: 0, height: 0)
var padding: UIEdgeInsets {
var hasText:Bool = false
if let t = self.text?.count, t > 0 {
hasText = true
@Achyut-Sagar
Achyut-Sagar / ImagePicker.swift
Last active December 5, 2019 11:04
Image Picker Controller
import UIKit
protocol ImagePickerDelegate {
func imagePicked(image: UIImage)
}
class ImagePicker: NSObject {
let presentingVC: UIViewController
var delegate: ImagePickerDelegate?
@Achyut-Sagar
Achyut-Sagar / Extension+UIDevice.swift
Created November 11, 2019 06:36
iOS Device Detector
import Foundation
import UIKit
extension UIDevice{
var deviceModel : DeviceFamily{
switch UIScreen.main.nativeBounds.height {
case 960:
return .iPhone_4
@Achyut-Sagar
Achyut-Sagar / Extension+UIView.swift
Last active October 9, 2021 06:11
Extension of UIview
extension UIView{
//MARK:- Frame Properties
var originPoint : CGPoint{
return self.frame.origin
}
var originX : CGFloat{
return self.frame.origin.x
}