2017-07-04 6 views
1

So ändern Sie den Rand der Suchleiste in die abgerundete Ecke. Unten ist mein Code und ich brauche die orangefarbene Umrandung nicht als scharfes Rechteck zu runden. Bitte helfenSuchleiste abgerundete Ecke

// Search bar 
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 60, 270, 41)]; 
self.searchBar.delegate = self; 
self.searchBar.placeholder = MEGLocalizedString(@"search_hint_home_screen", nil); 
UIColor *searchBarBackgroundColor = [UIColor clearColor]; 
self.searchBar.backgroundImage = [UIImage imageFromColor:searchBarBackgroundColor]; 
[self.searchBar setImage:[[UIImage imageNamed:@"search_icon_general.png"] imageTintedWithColor:primaryEventColor] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal]; 
    UIView *textField = [self.searchBar subviewWithKindOfClass:[UITextField class]]; 
    textField.backgroundColor = [UIColor orangeColor]; 
//  textField.layer.borderWidth = 1; 
    textField.layer.cornerRadius = 14; 
    [(UITextField *)textField setBorderStyle:UITextBorderStyleNone]; 
    // Change the search bar placeholder text color 
    [textField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"]; 
} 
self.searchBar.layer.cornerRadius = 14; 
self.searchBar.layer.borderColor = [UIColor orangeColor].CGColor; 

enter image description here

+1

Versuchen: self.searchBar.layer.masksToBounds = true self.searchBar.clipsToBounds = true – ninjaproger

Antwort

1

Diese lösen Ihr Problem

textField.layer.masksToBounds = true

Verwandte Themen