Skip to content

Instantly share code, notes, and snippets.

View ilia3546's full-sized avatar
🧙

Ilya Kharlamov ilia3546

🧙
View GitHub Profile
@ilia3546
ilia3546 / UISearchBarWithCustomButtonExample.swift
Created March 14, 2024 14:38
Add a custom button between UISearchBar and Cancel button while a search is enabled
private lazy var customSearchButton = UIButton(
type: .contactAdd,
primaryAction: UIAction(handler: { _ in })
)
private func configureSearchController() {
let searchController = UISearchController(searchResultsController: /*YOUR_SEARCH_CONTROLLER*/)
searchController.delegate = self
// Set custom leading padding to the cancel button (size of our button + some padding)
@ilia3546
ilia3546 / UIColor+Blend.swift
Created January 19, 2023 11:32
Blending two UIColor's. Swift implementation of JordanDelcros's JS algorithm https://gist.github.com/JordanDelcros/518396da1c13f75ee057
import UIKit
public extension UIColor {
/**
Blend current color with some overlay
Source - [JordanDelcros's JS algorithm](https://gist.github.com/JordanDelcros/518396da1c13f75ee057)
*/
func blended(with overlay: UIColor) -> UIColor {
@ilia3546
ilia3546 / UIStatusBarManager+ScrollToTop.swift
Last active December 22, 2022 08:55
Tap simulation on UIStatusBar for manual scrolling to top. Dangerous - Private API!
import UIKit
public extension UIStatusBarManager {
func scrollToTop() {
let selector = NSSelectorFromString("handleTapAction:")
let action = UIStatusBarTapAction()
perform(selector, with: action)
}
}