### Install PYSearch via CocoaPods Source: https://context7.com/ko1o/pysearch/llms.txt Add PYSearch to your Podfile to include it in your project. Import the umbrella header to access public APIs. ```ruby # Podfile pod 'PYSearch' ``` ```objc // In any file that uses PYSearch #import ``` -------------------------------- ### Localization Support for PYSearch Strings Source: https://context7.com/ko1o/pysearch/llms.txt PYSearch includes string bundles for multiple languages. Override default strings by providing keys in your app's Localizable.strings file. This example shows how to add custom strings for English. ```strings // en.lproj/Localizable.strings additions in your app target "PYSearchSearchPlaceholderText" = "Search…"; "PYSearchHotSearchText" = "Trending"; "PYSearchSearchHistoryText" = "Recent"; "PYSearchEmptySearchHistoryText" = "No recent searches"; "PYSearchCancelButtonText" = "Cancel"; "PYSearchBackButtonText" = "Back"; ``` -------------------------------- ### Implement PYSearchViewControllerDelegate Methods Source: https://context7.com/ko1o/pysearch/llms.txt Implement delegate methods to respond to user interactions such as search submission, hot-search taps, history taps, suggestion taps, text changes, cancellation, and back navigation. This allows for fine-grained control over the search flow. ```objc @interface MyViewController () @end @implementation MyViewController // Called when the user submits a search (keyboard Return or suggestion tap) - (void)searchViewController:(PYSearchViewController *)searchViewController didSearchWithSearchBar:(UISearchBar *)searchBar searchText:(NSString *)searchText { NSLog(@"Search submitted: %@", searchText); [searchViewController.navigationController pushViewController: [[ResultsViewController alloc] initWithQuery:searchText] animated:YES]; } // Called when search text changes — ideal for live suggestion fetching - (void)searchViewController:(PYSearchViewController *)searchViewController searchTextDidChange:(UISearchBar *)searchBar searchText:(NSString *)searchText { if (searchText.length == 0) return; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // Simulate network fetch NSMutableArray *suggestions = [NSMutableArray array]; for (int i = 0; i < 8; i++) { [suggestions addObject:[NSString stringWithFormat:@"%@ result %d", searchText, i]]; } searchViewController.searchSuggestions = suggestions; // triggers automatic reload }); } // Called when a hot search tag is tapped (overrides didSearchWithSearchBar when implemented) - (void)searchViewController:(PYSearchViewController *)searchViewController didSelectHotSearchAtIndex:(NSInteger)index searchText:(NSString *)searchText { NSLog(@"Hot search tapped at index %ld: %@", (long)index, searchText); } // Called when a history entry is tapped - (void)searchViewController:(PYSearchViewController *)searchViewController didSelectSearchHistoryAtIndex:(NSInteger)index searchText:(NSString *)searchText { NSLog(@"History item tapped: %@", searchText); } // Called when cancel button is pressed - (void)didClickCancel:(PYSearchViewController *)searchViewController { [searchViewController dismissViewControllerAnimated:YES completion:nil]; } @end ``` -------------------------------- ### Create Search Controller with Block Callback Source: https://context7.com/ko1o/pysearch/llms.txt Use this factory method to create a `PYSearchViewController` with hot search tags and a block callback for search events. The block is invoked when the user submits a search query. ```objc NSArray *hotSearches = @[@"Java", @"Python", @"Objective-C", @"Swift", @"C", @"C++", @"PHP", @"Go", @"JavaScript", @"Ruby"]; PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:hotSearches searchBarPlaceholder:@"Search programming language" didSearchBlock:^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) { // searchText is the confirmed search query NSLog(@"User searched: %@", searchText); ResultsViewController *resultsVC = [[ResultsViewController alloc] initWithQuery:searchText]; [searchViewController.navigationController pushViewController:resultsVC animated:YES]; }]; // Present modally inside a navigation controller UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchVC]; [self presentViewController:nav animated:NO completion:nil]; ``` -------------------------------- ### Initialize PYSearchViewController with Hot Searches Source: https://github.com/ko1o/pysearch/blob/master/README.md Use this snippet to create and present the PYSearchViewController. Provide an array of hot search terms and a placeholder for the search bar. A block is executed upon search completion, allowing for navigation or other actions. ```objc // 1. Create hotSearches array NSArray *hotSeaches = @[@"Java", @"Python", @"Objective-C", @"Swift", @"C", @"C++", @"PHP", @"C#", @"Perl", @"Go", @"JavaScript", @"R", @"Ruby", @"MATLAB"]; // 2. Create searchViewController PYSearchViewController *searchViewController = [PYSearchViewController searchViewControllerWithHotSearches:hotSeaches searchBarPlaceholder:@"Search programming language" didSearchBlock:^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) { // Call this Block when completion search automatically // Such as: Push to a view controller [searchViewController.navigationController pushViewController:[[UIViewController alloc] init] animated:YES]; }]; // 3. present the searchViewController UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchViewController]; [self presentViewController:nav animated:NO completion:nil]; ``` -------------------------------- ### PYSearchViewControllerDelegate Source: https://context7.com/ko1o/pysearch/llms.txt The delegate protocol provides fine-grained callbacks for every user interaction: text submission, hot-search tap, history tap, suggestion tap, text change, cancel, and back. ```APIDOC ## `PYSearchViewControllerDelegate` — Respond to search events The delegate protocol provides fine-grained callbacks for every user interaction: text submission, hot-search tap, history tap, suggestion tap, text change, cancel, and back. ```objc @interface MyViewController () @end @implementation MyViewController // Called when the user submits a search (keyboard Return or suggestion tap) - (void)searchViewController:(PYSearchViewController *)searchViewController didSearchWithSearchBar:(UISearchBar *)searchBar searchText:(NSString *)searchText { NSLog(@"Search submitted: %@", searchText); [searchViewController.navigationController pushViewController: [[ResultsViewController alloc] initWithQuery:searchText] animated:YES]; } // Called when search text changes — ideal for live suggestion fetching - (void)searchViewController:(PYSearchViewController *)searchViewController searchTextDidChange:(UISearchBar *)searchBar searchText:(NSString *)searchText { if (searchText.length == 0) return; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // Simulate network fetch NSMutableArray *suggestions = [NSMutableArray array]; for (int i = 0; i < 8; i++) { [suggestions addObject:[NSString stringWithFormat:@"%@ result %d", searchText, i]]; } searchViewController.searchSuggestions = suggestions; // triggers automatic reload }); } // Called when a hot search tag is tapped (overrides didSearchWithSearchBar when implemented) - (void)searchViewController:(PYSearchViewController *)searchViewController didSelectHotSearchAtIndex:(NSInteger)index searchText:(NSString *)searchText { NSLog(@"Hot search tapped at index %ld: %@", (long)index, searchText); } // Called when a history entry is tapped - (void)searchViewController:(PYSearchViewController *)searchViewController didSelectSearchHistoryAtIndex:(NSInteger)index searchText:(NSString *)searchText { NSLog(@"History item tapped: %@", searchText); } // Called when cancel button is pressed - (void)didClickCancel:(PYSearchViewController *)searchViewController { [searchViewController dismissViewControllerAnimated:YES completion:nil]; } @end ``` ``` -------------------------------- ### `+searchViewControllerWithHotSearches:searchBarPlaceholder:` Source: https://context7.com/ko1o/pysearch/llms.txt A simpler factory method to create a `PYSearchViewController` without a block callback, intended for use with the `PYSearchViewControllerDelegate` protocol. ```APIDOC ## `+searchViewControllerWithHotSearches:searchBarPlaceholder:` — Create search controller without block Lightweight factory method for cases where you prefer to receive search events through the `PYSearchViewControllerDelegate` protocol rather than a block. ```objc PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:@[@"Swift", @"Xcode", @"UIKit"] searchBarPlaceholder:@"Search Apple technologies"]; searchVC.delegate = self; // Push instead of modal presentation searchVC.searchViewControllerShowMode = PYSearchViewControllerShowModePush; [self.navigationController pushViewController:searchVC animated:YES]; ``` ``` -------------------------------- ### Create Search Controller without Block Callback Source: https://context7.com/ko1o/pysearch/llms.txt A lightweight factory method for creating a `PYSearchViewController` when you prefer to handle search events via the `PYSearchViewControllerDelegate` protocol. ```objc PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:@[@"Swift", @"Xcode", @"UIKit"] searchBarPlaceholder:@"Search Apple technologies"]; searchVC.delegate = self; // Push instead of modal presentation searchVC.searchViewControllerShowMode = PYSearchViewControllerShowModePush; [self.navigationController pushViewController:searchVC animated:YES]; ``` -------------------------------- ### Localization Support Source: https://context7.com/ko1o/pysearch/llms.txt PYSearch includes string bundles for multiple languages. Override displayed strings by providing keys in your own Localizable.strings. ```APIDOC ## Localization support PYSearch includes string bundles for English, Spanish, French, Simplified Chinese, and Traditional Chinese. Override displayed strings by providing keys in your own `Localizable.strings`. ``` // en.lproj/Localizable.strings additions in your app target "PYSearchSearchPlaceholderText" = "Search…"; "PYSearchHotSearchText" = "Trending"; "PYSearchSearchHistoryText" = "Recent"; "PYSearchEmptySearchHistoryText" = "No recent searches"; "PYSearchCancelButtonText" = "Cancel"; "PYSearchBackButtonText" = "Back"; ``` ```objc // Force a specific locale at runtime (useful for testing) [[NSUserDefaults standardUserDefaults] setObject:@["zh-Hans"] forKey:@"AppleLanguages"]; [[NSUserDefaults standardUserDefaults] synchronize]; ``` ``` -------------------------------- ### Implement Custom Search Suggestions Data Source Source: https://github.com/ko1o/pysearch/blob/master/README.md To enable custom search suggestions, set the dataSource property of the search view controller to self and implement the required dataSource methods. ```objc // 1. Set dataSource searchViewController.dataSource = self; // 2. Implement dataSource method ``` -------------------------------- ### `+searchViewControllerWithHotSearches:searchBarPlaceholder:didSearchBlock:` Source: https://context7.com/ko1o/pysearch/llms.txt Creates a `PYSearchViewController` instance using a block callback for search events. It takes an array of hot search tags, a placeholder for the search bar, and a block that is executed when a search is performed. ```APIDOC ## `+searchViewControllerWithHotSearches:searchBarPlaceholder:didSearchBlock:` — Create search controller with block callback The primary factory method for creating a `PYSearchViewController`. Accepts an array of hot-search strings to display as tags, a placeholder string for the search bar, and a completion block invoked automatically when the user submits a search. ```objc NSArray *hotSearches = @[@"Java", @"Python", @"Objective-C", @"Swift", @"C", @"C++", @"PHP", @"Go", @"JavaScript", @"Ruby"]; PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:hotSearches searchBarPlaceholder:@"Search programming language" didSearchBlock:^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) { // searchText is the confirmed search query NSLog(@"User searched: %@", searchText); ResultsViewController *resultsVC = [[ResultsViewController alloc] initWithQuery:searchText]; [searchViewController.navigationController pushViewController:resultsVC animated:YES]; }]; // Present modally inside a navigation controller UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchVC]; [self presentViewController:nav animated:NO completion:nil]; ``` ``` -------------------------------- ### Set Search Result Show Mode Source: https://github.com/ko1o/pysearch/blob/master/README.md Configure how search results are displayed. The default mode is PYSearchResultShowModeCustom. ```objc // Set searchResultShowMode searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed; ``` -------------------------------- ### Configure Custom Search Result Display Source: https://github.com/ko1o/pysearch/blob/master/README.md Customize the display of search results by setting the searchResultShowMode to PYSearchResultShowModeEmbed and providing a custom searchResultController. ```objc // 1. Set searchResultShowMode searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed; // 2. Set searchResultController searchViewController.searchResultController = [[UIViewController alloc] init]; ``` -------------------------------- ### Configure Search Result Display Mode Source: https://context7.com/ko1o/pysearch/llms.txt Determines how the search result view controller is presented. Choose between embed, push, or custom modes. The embed mode shows results within the PYSearchViewController, push mode uses the navigation stack, and custom mode requires manual handling. ```objc // --- Embed mode: result view is embedded inside PYSearchViewController --- MyResultsViewController *resultsVC = [[MyResultsViewController alloc] init]; searchVC.searchResultShowMode = PYSearchResultShowModeEmbed; searchVC.searchResultController = resultsVC; // Optionally show results immediately as the user types searchVC.showSearchResultWhenSearchTextChanged = YES; // --- Push mode: result view is pushed onto the navigation stack automatically --- searchVC.searchResultShowMode = PYSearchResultShowModePush; searchVC.searchResultController = [[MyResultsViewController alloc] init]; // --- Custom mode (default): handle navigation yourself in the delegate/block --- searchVC.searchResultShowMode = PYSearchResultShowModeCustom; ``` -------------------------------- ### Implement Custom Search Suggestion Cells with PYSearchDataSource Source: https://context7.com/ko1o/pysearch/llms.txt Implement PYSearchViewControllerDataSource to provide custom UITableViewCell layouts for search suggestions. Ensure your view controller conforms to the protocol and implements the required methods for cell configuration and sizing. ```objc @interface MyViewController () @property (nonatomic, strong) NSArray *suggestions; @end @implementation MyViewController - (void)setupSearch { PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:@[@"Swift", @"Objective-C"] searchBarPlaceholder:@"Search"]; searchVC.dataSource = self; // enables custom suggestion cells // ... } - (NSInteger)searchSuggestionView:(UITableView *)view numberOfRowsInSection:(NSInteger)section { return self.suggestions.count; } - (UITableViewCell *)searchSuggestionView:(UITableView *)view cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellID = @"SuggestionCell"; UITableViewCell *cell = [view dequeueReusableCellWithIdentifier:cellID]; if (!cell) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID]; NSDictionary *item = self.suggestions[indexPath.row]; cell.textLabel.text = item[@"title"]; cell.detailTextLabel.text = item[@"subtitle"]; cell.imageView.image = [UIImage systemImageNamed:@"magnifyingglass"]; return cell; } - (CGFloat)searchSuggestionView:(UITableView *)view heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 56.0; } - (NSInteger)numberOfSectionsInSearchSuggestionView:(UITableView *)view { return 1; } @end ``` -------------------------------- ### Set Search History Style Source: https://github.com/ko1o/pysearch/blob/master/README.md Customize the appearance of search history items. The default style is PYSearchHistoryStyleCell. ```objc // Set searchHistoryStyle searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag; ``` -------------------------------- ### Configure Hot Search Tag Visual Style Source: https://context7.com/ko1o/pysearch/llms.txt Customize the appearance of hot search tags by setting the `hotSearchStyle` property to one of the provided `PYHotSearchStyle` enum values. Additional customization options are available for specific styles. ```objc PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:hotSearches searchBarPlaceholder:@"Search"]; // Available styles: // PYHotSearchStyleNormalTag – plain tag, no border // PYHotSearchStyleColorfulTag – random colorful background (customizable via colorPol) // PYHotSearchStyleBorderTag – transparent background with border // PYHotSearchStyleARCBorderTag – rounded-corner border tag // PYHotSearchStyleRankTag – numbered rank tags with custom background colors // PYHotSearchStyleRectangleTag – rectangular transparent tag searchVC.hotSearchStyle = PYHotSearchStyleColorfulTag; // Customize the color pool for colorful tags searchVC.colorPol = [@[ [UIColor systemRedColor], [UIColor systemBlueColor], [UIColor systemOrangeColor], [UIColor systemGreenColor] ] mutableCopy]; // For rank tag style, supply exactly four hex color strings searchVC.hotSearchStyle = PYHotSearchStyleRankTag; searchVC.rankTagBackgroundColorHexStrings = @[@"#FF6B6B", @"#FFA500", @"#4ECDC4", @"#95A5A6"]; ``` -------------------------------- ### Set Search Histories Cache Path Source: https://github.com/ko1o/pysearch/blob/master/README.md Specify a custom path for caching search histories. The default path is PYSEARCH_SEARCH_HISTORY_CACHE_PATH. ```objc // Set searchHistoriesCachePath searchViewController.searchHistoriesCachePath = @"The cache path"; ``` -------------------------------- ### Custom Search Suggestion Cells Source: https://context7.com/ko1o/pysearch/llms.txt Implement PYSearchViewControllerDataSource to replace the default suggestion list with fully custom UITableViewCell layouts. ```APIDOC ## `dataSource` — Custom search suggestion cells Implement `PYSearchViewControllerDataSource` to replace the default suggestion list with fully custom `UITableViewCell` layouts. ```objc @interface MyViewController () @property (nonatomic, strong) NSArray *suggestions; @end @implementation MyViewController - (void)setupSearch { PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:@["Swift", "Objective-C"] searchBarPlaceholder:@"Search"]; searchVC.dataSource = self; // enables custom suggestion cells // ... } - (NSInteger)searchSuggestionView:(UITableView *)view numberOfRowsInSection:(NSInteger)section { return self.suggestions.count; } - (UITableViewCell *)searchSuggestionView:(UITableView *)view cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellID = @"SuggestionCell"; UITableViewCell *cell = [view dequeueReusableCellWithIdentifier:cellID]; if (!cell) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID]; NSDictionary *item = self.suggestions[indexPath.row]; cell.textLabel.text = item[@"title"]; cell.detailTextLabel.text = item[@"subtitle"]; cell.imageView.image = [UIImage systemImageNamed:@"magnifyingglass"]; return cell; } - (CGFloat)searchSuggestionView:(UITableView *)view heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 56.0; } - (NSInteger)numberOfSectionsInSearchSuggestionView:(UITableView *)view { return 1; } @end ``` ``` -------------------------------- ### Configure Search History Display Style Source: https://context7.com/ko1o/pysearch/llms.txt Controls how previously recorded search entries are displayed. You can set the style, limit the number of stored entries, override the cache path, or hide search history entirely. ```objc searchVC.searchHistoryStyle = PYSearchHistoryStyleBorderTag; // Cap the number of stored history entries (default: 20) searchVC.searchHistoriesCount = 10; // Override the default cache file path (default: Documents/PYSearchhistories.plist) searchVC.searchHistoriesCachePath = [[NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"MyAppSearchHistory.plist"]; // Hide search history entirely searchVC.showSearchHistory = NO; ``` -------------------------------- ### Search Bar Appearance Customization Source: https://context7.com/ko1o/pysearch/llms.txt PYSearchViewController exposes direct access to the search bar and its text field for visual customization. ```APIDOC ## Search bar appearance customization `PYSearchViewController` exposes direct access to the search bar and its text field for visual customization. ```objc PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:hotSearches searchBarPlaceholder:@"Search"]; // Background color of the search bar container searchVC.searchBarBackgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.97 alpha:1.0]; // Corner radius of the search field background searchVC.searchBarCornerRadius = 10.0; // Customize cancel button title searchVC.cancelButton.setTitle(@"Done", forState: UIControlStateNormal); // Access the underlying UISearchBar and UITextField directly searchVC.searchBar.tintColor = [UIColor systemBlueColor]; searchVC.searchTextField.font = [UIFont systemFontOfSize:15.0]; // Swap hot searches and history section order (not effective with Cell history style) searchVC.swapHotSeachWithSearchHistory = YES; // Hide suggestion dropdown searchVC.searchSuggestionHidden = YES; ``` ``` -------------------------------- ### Set Search Histories Count Source: https://github.com/ko1o/pysearch/blob/master/README.md Control the maximum number of search histories to be displayed. The default count is 20. ```objc // Set searchHistoriesCount searchViewController. searchHistoriesCount = 6; ``` -------------------------------- ### Set Hot Search Style Source: https://github.com/ko1o/pysearch/blob/master/README.md Customize the appearance of hot search tags. The default style is PYHotSearchStyleNormalTag. ```objc // Set hotSearchStyle searchViewController.hotSearchStyle = PYHotSearchStyleColorfulTag; ``` -------------------------------- ### Force a Specific Locale at Runtime in PYSearch Source: https://context7.com/ko1o/pysearch/llms.txt Force a specific locale at runtime for testing localization in PYSearch. This is achieved by setting the 'AppleLanguages' user default. ```objc // Force a specific locale at runtime (useful for testing) [[NSUserDefaults standardUserDefaults] setObject:@[@"zh-Hans"] forKey:@"AppleLanguages"]; [[NSUserDefaults standardUserDefaults] synchronize]; ``` -------------------------------- ### searchResultShowMode Source: https://context7.com/ko1o/pysearch/llms.txt Determines how the search result view controller is presented when the user confirms a search. Three modes are available: custom (default), push, or embed. ```APIDOC ## `searchResultShowMode` — Configure result display mode Determines how the search result view controller is presented when the user confirms a search. Three modes are available: custom (default), push, or embed. ```objc // --- Embed mode: result view is embedded inside PYSearchViewController --- MyResultsViewController *resultsVC = [[MyResultsViewController alloc] init]; searchVC.searchResultShowMode = PYSearchResultShowModeEmbed; searchVC.searchResultController = resultsVC; // Optionally show results immediately as the user types searchVC.showSearchResultWhenSearchTextChanged = YES; // --- Push mode: result view is pushed onto the navigation stack automatically --- searchVC.searchResultShowMode = PYSearchResultShowModePush; searchVC.searchResultController = [[MyResultsViewController alloc] init]; // --- Custom mode (default): handle navigation yourself in the delegate/block --- searchVC.searchResultShowMode = PYSearchResultShowModeCustom; ``` ``` -------------------------------- ### Set Search Suggestion Hidden Source: https://github.com/ko1o/pysearch/blob/master/README.md Control the visibility of search suggestions. The default value is NO (visible). ```objc // Set searchSuggestionHidden searchViewController.searchSuggestionHidden = YES; ``` -------------------------------- ### `hotSearchStyle` Source: https://context7.com/ko1o/pysearch/llms.txt Configures the visual style of the hot search tags. This property accepts values from the `PYHotSearchStyle` enum to customize the appearance of tags, with options for normal, colorful, bordered, ranked, and rectangular styles. ```APIDOC ## `hotSearchStyle` — Configure hot search tag visual style Set the `hotSearchStyle` property to one of six built-in `PYHotSearchStyle` enum values to change how popular-search tags are rendered. The default is `PYHotSearchStyleNormalTag`. ```objc PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:hotSearches searchBarPlaceholder:@"Search"]; // Available styles: // PYHotSearchStyleNormalTag – plain tag, no border // PYHotSearchStyleColorfulTag – random colorful background (customizable via colorPol) // PYHotSearchStyleBorderTag – transparent background with border // PYHotSearchStyleARCBorderTag – rounded-corner border tag // PYHotSearchStyleRankTag – numbered rank tags with custom background colors // PYHotSearchStyleRectangleTag – rectangular transparent tag searchVC.hotSearchStyle = PYHotSearchStyleColorfulTag; // Customize the color pool for colorful tags searchVC.colorPol = [@[ [UIColor systemRedColor], [UIColor systemBlueColor], [UIColor systemOrangeColor], [UIColor systemGreenColor] ] mutableCopy]; // For rank tag style, supply exactly four hex color strings searchVC.hotSearchStyle = PYHotSearchStyleRankTag; searchVC.rankTagBackgroundColorHexStrings = @[@"#FF6B6B", @"#FFA500", @"#4ECDC4", @"#95A5A6"]; ``` ``` -------------------------------- ### Customize Search Bar Appearance in PYSearchViewController Source: https://context7.com/ko1o/pysearch/llms.txt Customize the visual appearance of the search bar and its text field using properties provided by PYSearchViewController. This includes background color, corner radius, cancel button title, and direct access to the underlying UISearchBar and UITextField. ```objc PYSearchViewController *searchVC = [PYSearchViewController searchViewControllerWithHotSearches:hotSearches searchBarPlaceholder:@"Search"]; // Background color of the search bar container searchVC.searchBarBackgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.97 alpha:1.0]; // Corner radius of the search field background searchVC.searchBarCornerRadius = 10.0; // Customize cancel button title searchVC.cancelButton.setTitle(@"Done", forState: UIControlStateNormal); // Access the underlying UISearchBar and UITextField directly searchVC.searchBar.tintColor = [UIColor systemBlueColor]; searchVC.searchTextField.font = [UIFont systemFontOfSize:15.0]; // Swap hot searches and history section order (not effective with Cell history style) searchVC.swapHotSeachWithSearchHistory = YES; // Hide suggestion dropdown searchVC.searchSuggestionHidden = YES; ``` -------------------------------- ### searchHistoryStyle Source: https://context7.com/ko1o/pysearch/llms.txt Controls how previously recorded search entries are displayed. Mirrors the hot-search style options plus a standard `UITableViewCell` row style. Default is `PYSearchHistoryStyleCell`. ```APIDOC ## `searchHistoryStyle` — Configure search history display style Controls how previously recorded search entries are displayed. Mirrors the hot-search style options plus a standard `UITableViewCell` row style. Default is `PYSearchHistoryStyleCell`. ```objc searchVC.searchHistoryStyle = PYSearchHistoryStyleBorderTag; // Cap the number of stored history entries (default: 20) searchVC.searchHistoriesCount = 10; // Override the default cache file path (default: Documents/PYSearchhistories.plist) searchVC.searchHistoriesCachePath = [[NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"MyAppSearchHistory.plist"]; // Hide search history entirely searchVC.showSearchHistory = NO; ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.