Skip to content

Instantly share code, notes, and snippets.

View WallabyStuff's full-sized avatar
🎯
Focusing

SeungGi LeE WallabyStuff

🎯
Focusing
View GitHub Profile
@c-villain
c-villain / Frame.swift
Created December 30, 2021 21:13
Must-have SwiftUI frame extensions
extension View {
// MARK: Vertical Center
func vCenter() -> some View {
self
.frame(maxHeight: .infinity, alignment: .center)
}
// MARK: Vertical Top
func vTop() -> some View {
@mecid
mecid / Calendar.swift
Last active July 10, 2024 09:17
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@almaleh
almaleh / SlowCPU-based.swift
Last active July 16, 2023 05:45
Slow CPU-based Drawing
class FreedrawingImageViewCG: UIImageView {
var currentTouchPosition: CGPoint?
override func layoutSubviews() {
super.layoutSubviews()
isUserInteractionEnabled = true
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
@adamgraham
adamgraham / UIColor+HSL.swift
Last active July 6, 2022 02:34
An extension of the iOS class UIColor to provide conversion to and from HSL (hue, saturation, lightness) colors.
/// An extension to provide conversion to and from HSL (hue, saturation, lightness) colors.
extension UIColor {
/// The HSL (hue, saturation, lightness) components of a color.
struct HSL: Hashable {
/// The hue component of the color, in the range [0, 360°].
var hue: CGFloat
/// The saturation component of the color, in the range [0, 100%].
var saturation: CGFloat
class LeftAlignedCollectionViewFlowLayout: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let attributes = super.layoutAttributesForElements(in: rect)
var leftMargin = sectionInset.left
var maxY: CGFloat = -1.0
attributes?.forEach { layoutAttribute in
if layoutAttribute.frame.origin.y >= maxY {
leftMargin = sectionInset.left
@usagimaru
usagimaru / NSImage+TintColor.swift
Last active October 12, 2023 13:39
NSImage+TintColor
import Cocoa
// This will work with Swift 5
extension NSImage {
func image(with tintColor: NSColor) -> NSImage {
if self.isTemplate == false {
return self
}
let image = self.copy() as! NSImage
@parmentf
parmentf / GitCommitEmoji.md
Last active July 29, 2024 04:56
Git Commit message Emoji