Skip to content

Commit

Permalink
Rough fix of UISearchBar scope view
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Sep 21, 2013
1 parent d9e9044 commit 45a4744
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 17 deletions.
33 changes: 33 additions & 0 deletions UI7Kit/UI7SearchBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@
#import "UI7Color.h"
#import "UI7SearchBar.h"


@interface UISearchBar (Private)

@property(retain) UIImage * scopeBarBackgroundImage;

@end


@interface UISearchBar (Accessor)

@property(readonly) UISegmentedControl *scopeBar;

@end


@implementation UISearchBar (Accessor)

NSAPropertyGetter(scopeBar, @"_scopeBar");

@end


@implementation UISearchBar (Patch)

- (id)__initWithCoder:(NSCoder *)aDecoder { assert(NO); return nil; }
Expand Down Expand Up @@ -43,6 +65,17 @@ - (void)_searchBarInit {
textField.background = nil;
}
}

self.scopeBarBackgroundImage = [self.backgroundColor image];

{
UIColor *tintColor = [[UI7Kit kit] tintColor];

UISegmentedControl *segmented = self.scopeBar;
segmented.clipsToBounds = NO;
segmented.layer.borderWidth = .0f;
segmented.tintColor = tintColor;
}
}

@end
Expand Down
18 changes: 1 addition & 17 deletions UI7KitTestApp/UITSegmentedControlViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,14 @@ @interface UITSegmentedControlViewController ()

@implementation UITSegmentedControlViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
- (void)viewDidLoad {
[super viewDidLoad];

UISegmentedControl *segmentedControl = [[[UISegmentedControl alloc] initWithItems:@[@"Item1", @"Item2", @"Item3"]] autorelease];
segmentedControl.frame = CGRectMake(20.0, 10.0, 280, segmentedControl.frame.size.height);
[self.view addSubview:segmentedControl];
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (void)colorChanged:(id)sender {
[super colorChanged:sender];
self.segmented1.tintColor = self.view.tintColor;
Expand Down

0 comments on commit 45a4744

Please sign in to comment.