CARVIEW |
Select Language
HTTP/2 302
date: Sat, 11 Oct 2025 06:42:38 GMT
content-type: text/html; charset=utf-8
content-length: 0
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
location: https://gist.github.com/orta/2667766
cache-control: no-cache
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
set-cookie: _gh_sess=n3JR50btl%2FJ9mmDZq%2FYb0G6ajW31ddXugaWhUvAjiq9pflraO6y4uWpqJU0vXlQZeTvodfTup0ziEMDMLhpsc4odxZ%2Fp0P0pg%2B5zOg9C1hVLtEF81pk2WGrG6748r5HTaDd36ZDMm1fMtTIBc%2FKfxEgL9Iydd03FHPejqe%2BiFzZ4o0HnoIsBS3XeDiKOlpUj6LfTQZIA5NFshl%2F98UXdAIJT9G5eK9htw2NmqrN0PXtDmh%2FX7QnW%2B8pftdoQ%2FLu%2BMOsBv7PMoFucnDrKIF96Ig%3D%3D--YKR%2B7jMPPbGHJJ79--LUlKBr1VxGILAoECNPABJw%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1670430295.1760164957; Path=/; Domain=github.com; Expires=Sun, 11 Oct 2026 06:42:37 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 11 Oct 2026 06:42:37 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: CB5E:12E1F8:3C1029:53CBBC:68E9FC5D
HTTP/2 200
date: Sat, 11 Oct 2025 06:42:38 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"5b7a2b042bcff4d0cd8071c17bea5446"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
x-github-request-id: CB5E:12E1F8:3C104D:53CBE5:68E9FC5D
Custom Search Bar · GitHub
Show Gist options
Save orta/2667766 to your computer and use it in GitHub Desktop.
{{ message }}
Instantly share code, notes, and snippets.
Created
May 12, 2012 17:25
-
Star
18
(18)
You must be signed in to star a gist -
Fork
4
(4)
You must be signed in to fork a gist
-
Save orta/2667766 to your computer and use it in GitHub Desktop.
Custom Search Bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ARSearchBar.h | |
// Artsy Folio | |
// | |
// Created by orta therox on 18/04/2012. | |
// Released under The MIT License | |
// https://www.opensource.org/licenses/mit-license.php | |
// | |
// Copyright (c) 2012 https://art.sy. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@interface ARSearchBar : UISearchBar | |
// Called from The SearchDisplayController Delegate | |
- (void)showCancelButton:(BOOL)show; | |
- (void)cancelSearchField; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ARSearchBar.m | |
// Artsy Folio | |
// | |
// Created by orta therox on 18/04/2012. | |
// Released under The MIT License | |
// https://www.opensource.org/licenses/mit-license.php | |
// | |
// Created by orta therox on 18/04/2012. | |
// Copyright (c) 2012 https://art.sy. All rights reserved. | |
// | |
[all our imports] | |
CGFloat ViewHeight = 32; | |
CGFloat ViewMargin = 6; | |
CGFloat TextfieldLeftMargin = 20; | |
CGFloat CancelAnimationDistance = 80; | |
@interface ARSearchBar (){ | |
UITextField *foundSearchTextField; | |
UIButton *overlayCancelButton; | |
} | |
@end | |
@implementation ARSearchBar | |
- (void)dealloc { | |
[[NSNotificationCenter defaultCenter] removeObserver:self]; | |
} | |
- (void)awakeFromNib { | |
[super awakeFromNib]; | |
// find textfield in subviews | |
for (int i = [self.subviews count] - 1; i >= 0; i--) { | |
UIView *subview = [self.subviews objectAtIndex:i]; | |
if ([subview.class isSubclassOfClass:[UITextField class]]) { | |
foundSearchTextField = (UITextField *)subview; | |
} | |
} | |
[self stylizeSearchTextField]; | |
[self createButton]; | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeOriginalCancel) name:UITextFieldTextDidBeginEditingNotification object:foundSearchTextField]; | |
} | |
- (void)setFrame:(CGRect)frame { | |
frame.size.height = ViewHeight + (ViewMargin * 2) + 4; | |
[super setFrame:frame]; | |
} | |
- (void)layoutSubviews { | |
[super layoutSubviews]; | |
// resize textfield | |
CGRect frame = foundSearchTextField.frame; | |
frame.size.height = ViewHeight; | |
frame.origin.y = ViewMargin; | |
frame.origin.x = ViewMargin; | |
frame.size.width -= ViewMargin / 2; | |
foundSearchTextField.frame = frame; | |
} | |
- (void)stylizeSearchTextField { | |
// Sets the background to a static black, and remove round edges | |
for (int i = [self.subviews count] - 1; i >= 0; i--) { | |
UIView *subview = [self.subviews objectAtIndex:i]; | |
// This is the gradient behind the textfield | |
if ([subview.description hasPrefix:@"<UISearchBarBackground"]) { | |
[subview removeFromSuperview]; | |
} | |
} | |
// now change the search | |
foundSearchTextField.borderStyle = UITextBorderStyleNone; | |
foundSearchTextField.backgroundColor = [UIColor whiteColor]; | |
foundSearchTextField.background = nil; | |
foundSearchTextField.text = @""; | |
foundSearchTextField.clearButtonMode = UITextFieldViewModeNever; | |
foundSearchTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, TextfieldLeftMargin, 0)]; | |
foundSearchTextField.placeholder = @""; | |
foundSearchTextField.font = [UIFont serifFontWithSize:ARFontSansLarge]; | |
} | |
- (void)createButton { | |
ARFlatButton *cancelButton = [ARFlatButton buttonWithType:UIButtonTypeCustom]; | |
[[cancelButton titleLabel] setFont:[UIFont sansSerifFontWithSize:ARFontSansSmall]]; | |
NSString *title = [@"Cancel" uppercaseString]; | |
[cancelButton setTitle:title forState:UIControlStateNormal]; | |
[cancelButton setTitle:title forState:UIControlStateHighlighted]; | |
CGRect buttonFrame = cancelButton.frame; | |
buttonFrame.origin.y = ViewMargin - 1; | |
buttonFrame.size.height = ViewHeight; | |
buttonFrame.size.width = 66; | |
buttonFrame.origin.x = self.frame.size.width - buttonFrame.size.width - ViewMargin + CancelAnimationDistance; | |
cancelButton.frame = buttonFrame; | |
[cancelButton addTarget:self action:@selector(cancelSearchField) forControlEvents:UIControlEventTouchUpInside]; | |
overlayCancelButton = cancelButton; | |
[self addSubview:overlayCancelButton]; | |
[self bringSubviewToFront:overlayCancelButton]; | |
} | |
#pragma mark deal with the cancel button | |
- (void)showCancelButton:(BOOL)show { | |
CGFloat distance = show? -CancelAnimationDistance : CancelAnimationDistance; | |
[UIView animateWithDuration:0.25 animations:^{ | |
overlayCancelButton.frame = CGRectOffset(overlayCancelButton.frame, distance, 0); | |
}]; | |
} | |
- (void)removeOriginalCancel { | |
// remove the original button | |
for (int i = [self.subviews count] - 1; i >= 0; i--) { | |
UIView *subview = [self.subviews objectAtIndex:i]; | |
if ([subview.class isSubclassOfClass:[UIButton class]]) { | |
if (subview.frame.size.height != ViewHeight) { | |
subview.hidden = YES; | |
} | |
} | |
} | |
} | |
- (void)cancelSearchField { | |
// tap the original button! | |
for (int i = [self.subviews count] - 1; i >= 0; i--) { | |
UIView *subview = [self.subviews objectAtIndex:i]; | |
if ([subview.class isSubclassOfClass:[UIButton class]]) { | |
if (subview.frame.size.height != ViewHeight) { | |
UIButton *realCancel = (UIButton *)subview; | |
[realCancel sendActionsForControlEvents: UIControlEventTouchUpInside]; | |
} | |
} | |
} | |
} | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by orta therox on 18/04/2012. | |
// Released under The MIT License | |
// https://www.opensource.org/licenses/mit-license.php | |
// | |
@implementation ARSearchViewController | |
//Our custom search view needs to know when to show / hide the cancel button | |
- (void) searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller { | |
[searchBar showCancelButton:YES]; | |
[UIView animateWithDuration:0.2 animations:^{ | |
searchPlaceholderLabel.alpha = 0; | |
}]; | |
} | |
- (void) searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller { | |
[searchBar showCancelButton:NO]; | |
[UIView animateWithDuration:0.2 animations:^{ | |
searchPlaceholderLabel.alpha = 1; | |
}]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can’t perform that action at this time.