Skip to content

Instantly share code, notes, and snippets.

@ksmandersen
ksmandersen / PaddedTextField.swift
Last active July 18, 2024 09:44
Best way to inset text inside a UITextField
import UIKit
open class PaddedTextField: UITextField {
public var textInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) {
didSet { setNeedsDisplay() }
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
@tijme
tijme / UITextViewPlaceholder.swift
Last active February 18, 2025 18:47
The correct way to implement a placeholder in a UITextView (Swift)
//
// UITextViewPlaceholder.swift
// TextViewPlaceholder
//
// Copyright (c) 2017 Tijme Gommers <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell