`

怎么把椭圆的UISearchBar改成圆角矩形?

 
阅读更多

 for (UIView *subview in self.searchBar.subviews) 
    {
        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])  
        {    
            [subview removeFromSuperview];  
        }
        if ([subview isKindOfClass:[UITextField class]]) {
            UITextField *textField = (UITextField *)subview;
            textField.borderStyle = UITextBorderStyleRoundedRect;
            UILabel *iView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 35, 20)];
            [iView setText:@"search"];
            [iView setFont:[UIFont systemFontOfSize:15.0]];
            [iView setTextColor:[UIColor grayColor]];
            textField.leftView = iView;
            textField.clearButtonMode = UITextFieldViewModeNever;
//            textField.rightViewMode = UITextFieldViewModeAlways;
            textField.returnKeyType = UIReturnKeyDone;
        }
    }
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics