美文网首页
iOS导航按添加搜索框

iOS导航按添加搜索框

作者: 字母大师 | 来源:发表于2018-01-22 09:49 被阅读0次
    UIView *View = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 35)];
    UIColor *color =  self.navigationController.navigationBar.barTintColor;
    [View setBackgroundColor:color];
    searchBar = [[UITextField alloc] init];
    searchBar.frame = CGRectMake(0, 0, 200, 35);
    searchBar.backgroundColor = color;
    searchBar.layer.cornerRadius = 18;
    searchBar.layer.masksToBounds = YES;
    [searchBar.layer setBorderWidth:8];
    [searchBar.layer setBorderColor:[UIColor whiteColor].CGColor];
    searchBar.placeholder = @"搜索内容";
    [View addSubview:searchBar];
    [self.navigationItem.titleView sizeToFit];
     self.navigationItem.titleView = View;

相关文章

网友评论

      本文标题:iOS导航按添加搜索框

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