A custom searchbar that helps you easily create animated dynamic placeholders.
.package(name: "DynamicSearchBarPlaceholders", url: "https://github.com/ataetgi/DynamicSearchBarPlaceholders", from: "1.0.0")
1. Download .zip file
2. Just drag and drop DynamicSearchBarPlaceholders folder to your project
let searchBar = DynamicSearchBar(placeholders: ["Swift", "Dynamic", "SearchBar", "Placeholders"])
searchBar.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(searchBar)
NSLayoutConstraint.activate([
searchBar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
searchBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
searchBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
searchBar.heightAnchor.constraint(equalToConstant: 60)
])
let searchBar = DynamicSearchBar(placeholders: ["Swift", "Dynamic", "SearchBar", "Placeholders"],
timeInterval: 2,
direction: .fromTop,
placeholdersOptions: [.infinite, .shuffle])
searchBar.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(searchBar)
NSLayoutConstraint.activate([
searchBar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
searchBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
searchBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
searchBar.heightAnchor.constraint(equalToConstant: 60)
])
searchBar.stopPlaceholders()
searchBar.resumePlaceholders()
placeholders -> Array of placeholder strings
timeInterval -> Placeholder animation interval time
direction -> Animation direction(it can be .fromTop, .fromBottom, .fromLeft, .fromRight)
placeholdersOptions -> Placeholder options array, it can include .infinite and .shuffle
MIT License, Copyright (c) 2023 Ata Etgi, @ataetgi