Skip to content

Instantly share code, notes, and snippets.

View apple-avadhesh's full-sized avatar
🎯
Focusing

Avadhesh Sharma apple-avadhesh

🎯
Focusing
View GitHub Profile
@shial4
shial4 / DateField.swift
Last active June 4, 2021 14:55
SwiftUI text field with date picker as keyboard accessory view and toolbar with done button
//
// DateField.swift
//
// Created by Szymon Lorenz on 22/2/20.
// Copyright © 2020 Szymon Lorenz. All rights reserved.
//
import SwiftUI
struct DateTextField: UIViewRepresentable {
@cleonps
cleonps / !Swift Snippets.md
Last active July 14, 2026 12:57
Swift Snippets
@marcuswestin
marcuswestin / SwiftUI WrapView handler approach.swift
Last active September 25, 2021 20:03
An approach for simplified wrapping of AppKit and UIKit views in SwiftUI
import SwiftUI
#if os(macOS)
typealias OSView = NSView
typealias OSViewRepresentable = NSViewRepresentable
#elseif os(iOS)
typealias OSView = UIView
typealias OSViewRepresentable = UIViewRepresentable
#endif
@suzp1984
suzp1984 / NSScreen+DeviceName.swift
Last active July 16, 2024 03:06
get display name from NSScreen
extension CGDirectDisplayID {
func getIOService() -> io_service_t {
var serialPortIterator = io_iterator_t()
var ioServ: io_service_t = 0
let matching = IOServiceMatching("IODisplayConnect")
let kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &serialPortIterator)
if KERN_SUCCESS == kernResult && serialPortIterator != 0 {
ioServ = IOIteratorNext(serialPortIterator)
@descorp
descorp / TagCloudCollectionView.swift
Created November 22, 2019 13:33
Swift TagCloudCollectionView
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
class EdgeInsetLabel: UILabel {
private let textInsets: UIEdgeInsets
init(inset: UIEdgeInsets) {
textInsets = inset
@quangDecember
quangDecember / UserDefaults+Codable+propertyWrapper.swift
Created November 21, 2019 02:29
property wrappers for saving to UserDefaults, generics or Codable
import Foundation
@propertyWrapper
struct UserDefault<T> {
let key: String
let defaultValue: T
init(_ key: String, defaultValue: T) {
self.key = key
@Zeta611
Zeta611 / ViewController.swift
Last active April 4, 2022 05:10
[ViewController Template] #iOS #template
//
// ViewController.swift
//
// Created by Jay Lee on 08/23/2019.
// Copyright © 2019 Jay Lee <jaeho.lee@snu.ac.kr>
// This work is free. You can redistribute it and/or modify it under the
// terms of the Do What The Fuck You Want To Public License, Version 2,
// as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
//
extension String {
func foregroundColor(_ color: UIColor) -> NSAttributedString {
NSAttributedString(string: self, attributes: [.foregroundColor : color])
}
func background(_ color: UIColor) -> NSAttributedString {
NSAttributedString(string: self, attributes: [.backgroundColor: color])
}
func underline(_ color: UIColor, style: NSUnderlineStyle = .single) -> NSAttributedString {
NSAttributedString(string: self, attributes: [.underlineColor: color, .underlineStyle: style.rawValue])
}
(lldb) po [[self view] _methodDescription]
<UIView: 0x7fbe93e01bd0>:
in UIView:
Class Methods:
+ (id) fallback_debugHierarchyChildGroupingID; (0x101d67dda)
+ (id) fallback_debugHierarchyObjectsInGroupWithID:(id)arg1 onObject:(id)arg2 outOptions:(id*)arg3; (0x101d67e72)
+ (id) fallback_debugHierarchyAdditionalGroupingIDs; (0x101d67df9)
+ (id) fallback_debugHierarchyValueForPropertyWithName:(id)arg1 onObject:(id)arg2 outOptions:(id*)arg3 outError:(id*)arg4; (0x101d69f8f)
+ (id) fallback_debugHierarchyPropertyDescriptions; (0x101d6806a)
+ (void) _mapkit_animateWithDuration:(double)arg1 animations:(^block)arg2 completion:(^block)arg3; (0x7fff27471b8f)
//
// RoundedShadowTableViewCell.swift
//
// Created by Patrick Dura on 08/03/2019.
// Inspired by https://github.com/schluete/GroupedTableViewWithShadows
//
import UIKit
class RoundedShadowTableViewCell: UITableViewCell {