美文网首页
更改SearchBar

更改SearchBar

作者: lzp_John | 来源:发表于2017-09-21 20:55 被阅读14次

- (void)layoutSubviews{

[super layoutSubviews];

for (UIView *view in self.subviews)

{

if ([view isKindOfClass:NSClassFromString(@"UIView")] && view.subviews.count > 0) {

for (UIView *subview in view.subviews) {

if ([subview isKindOfClass:NSClassFromString(@"UITextField")]) {

UITextField *textField = (UITextField *)subview;

CGRect frame = textField.frame;

frame.size.height = 40;

textField.frame = frame;

textField.tintColor = [UIColor grayColor];

//光标

textField.font = [UIFont systemFontOfSize:16.0];

textField.textColor = [UIColor grayColor];

textField.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1];

textField.layer.cornerRadius = 14.f;

textField.layer.masksToBounds = YES;

//放大镜

UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 18, 18)];

image.image = [UIImage imageNamed:@"quanzi_searchIcon"];

image.backgroundColor = [UIColor clearColor];

textField.leftView = image;

break;

}

}

break;

}

}

}

相关文章

网友评论

      本文标题:更改SearchBar

      本文链接:https://www.haomeiwen.com/subject/esitextx.html