设置UINavigationBar的titleView和UISearchBar背景透明
代码语言:javascript
复制self.titleSearchBar = UISearchBar(frame: CGRectMake(0,0,200,44));
self.titleSearchBar.backgroundColor = UIColor.clearColor();
self.titleSearchBar.barStyle = UIBarStyle.BlackTranslucent;
self.titleSearchBar.placeholder = "搜索你感兴趣的主题和回复";
for sView in self.titleSearchBar.subviews[0].subviews{
if(sView.isKindOfClass(NSClassFromString("UISearchBarBackground")!)){
sView.removeFromSuperview();
}
}
self.titleSearchBar.delegate = self;
self.navigationItem.titleView = self.titleSearchBar;