• Stars
    star
    253
  • Rank 160,776 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The search bar that doesn't suck.

Twitter Follow Twitter Follow Version Swift Versions Platforms Codebeat License Donate

SHSearchBar

The clean and shiny search bar that does what UISearchBar does only with dirty hacks. This view is designed to tackle the customization limits of UISearchBar. The difference here is that this class does not inherit UISearchBar but composes a new UIView object by using a UITextField that is much easier to use. These are the limits of the UISearchBar:

  • no clean way to left align the placeholder
  • the cancel button is hard to tailor to your needs
  • generally the appearance is not customizable (e.g. the font of the text)
  • there are some strange behaviors when you set a custom background image

Since I use a UITextField these restrictions do not apply.

Installation

Swift Package Manager

In Xcode open your target list and select your project. Click the tab Swift Packages and there the small + icon. Enter the URL of this repository, select the version you want to install - usually the preset is okay - and confirm.

CocoaPods

Since SHSearchBar uses localized resources I dropped CocoaPods support in favor of SPM from version 2.0.0. Please integrate the package via SPM (see above).

Carthage

Since SHSearchBar uses localized resources I dropped Carthage support in favor of SPM from version 2.0.0. Please integrate the package via SPM (see above).

Examples

The repo includes an example project. It shows shows different use cases of the search bar. To run it, just open and run ./Example/SHSearchBarExample.xcodeproj. The following images show some use cases:

You can show a custom placeholder like for normal text fields:
Placeholder

And you can even type text into that searchbar:
Text

Wow there are customizable accessory views too:
Accesssory Icon

Easily customize text and cancel button as you want:
Customizable text and ancel button

You can customize each corner radius of the text field so that layouts like this become an ease:
Corner Radius Customization

The inner text field supports the new iOS 10 'textContentMode':
(Re-uses the address searched in Apple Maps before)
UITextContentMode Support

You can use the search bar inside a UINavigationBar:
UINavigationBar Support

Code Documentation

The code documentation is generated and hosted by Swift Package Index (powered by DocC)

Release

To release this Swift package the following steps have to be taken:

  • Create a new branch release-x.y.z
  • Run bash <(curl -H -s https://raw.githubusercontent.com/Blackjacx/Scripts/master/frameworks/bootstrap.sh) to update to the latest shared development files
  • Run bundle update to update all Ruby gems
  • Commit all changes, make a PR and merge it to develop
  • Run bundle exec fastlane release framework:"SHSearchBar" version:"x.y.z" to release the new version
  • Post the following on Twitter
SHSearchBar release x.y.z 🎉

▸ 🚀  SHSearchBar (x.y.z) successfully published
▸ 📅  September 2nd
▸ 🌎  https://swiftpackageindex.com/Blackjacx/SHSearchBar
▸ 🌎  https://github.com/Blackjacx/SHSearchBar/releases/latest
▸ 👍  Tell your friends!

#spm #search #ios #apple #xcode #uisearchbar #swiftpackagemanager

Contribution

  • If you found a bug, please open an issue.
  • If you have a feature request, please open an issue.
  • If you want to contribute, please submit a pull request.

Author

Stefan Herold🐦 @Blackjacxxx

Contributors

Thanks to all of you who are part of this:

License

SHSearchBar is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

WWDC

You don't have the time to watch all the WWDC session videos yourself? No problem me and many contributors extracted the gist for you 🥳
Shell
2,590
star
2

Assist

App Store Connect API access via CLI written in Swift
Swift
32
star
3

Columbus

A feature-rich country picker for iOS, tvOS and watchOS.
Swift
32
star
4

StickyHeaderFlowLayout

Imitation of the sticky headers known from UITableViews
Swift
26
star
5

Development

Various guides and information related to mobile development 🧑‍💻
19
star
6

Playgrounds

Some playgrounds to play with
Swift
11
star
7

Scripts

A warm, central place for commonly used scripts
Shell
9
star
8

Gasoline

You ever wanted to track your gas costs? Then this app is just for you!
Swift
6
star
9

backlog-notifier

Automatically create comments in tickets, including the release version, e.g. at when a PR gets released.
JavaScript
6
star
10

Source

Tired of implementing the data sources over and over again? Want to use a lightweight solution that does not mess up your view controllers? Then this is for you! The generic data source implementation for all your view controllers, that supports UITableView, UICollectionView and NSFetchedResultsController
Swift
6
star
11

ASCKit

The backbone of my App Store Connect related software
Swift
5
star
12

Engine

The engine that powers all my packages, tools and apps.
Swift
5
star
13

SHDataSources

Project-independent, block-based data sources for UITableView and UICollectionView
Objective-C
4
star
14

SHDateFormatter

A date formatter supporting encoding as well as decoding of many different date and time formats including the often used ISO8601 standard.
Swift
4
star
15

NSURLRequest-SHLogging

Your dev ops ask you to provide some detail for failing requests? Take a look at this simple category for logging all details of a NSURLRequest. They will be thankful and you'll solve problems much faster!
Ruby
4
star
16

ConferenceCalendar

List of interesting tech conferences throughout the year including most important related information 👩‍💻
Shell
3
star
17

PublicCodeLibrary

🚨 THIS REPOSITORY HAS BEEN ARCHIVED IN FAVOR OF https://github.com/Blackjacx/Engine 🚨
Objective-C
3
star
18

Emojis

View all the Emojis - A SwiftUI Project 🥳
Swift
2
star
19

Quickie

Tired of creating all the boilerplate code from scratch every time you start a new project? Here is the solution. A Swift package that provides extensions to the most common functionality in the iOS and macOS world to significantly speed up development process.
Swift
2
star
20

SignInWithApple

Slides & demo project for heise MacDev 2019
1
star
21

xcode-snippets

Code snippets synced with the Xcode snippets folder
Objective-C
1
star
22

Starter

This is a starting point that can be used to setup a new iOS project.
Shell
1
star
23

RADToolKit

🚨 THIS REPOSITORY HAS BEEN ARCHIVED IN FAVOR OF https://github.com/Blackjacx/Engine 🚨
Swift
1
star
24

sample-code

samples for many situations
Swift
1
star