在APP中经常用到UISearchBar,下面介绍在Swift中如何使用。
一、效果图 二、实现代码let searchBar = UISearchBar(frame: CGRect(x: 20, y: 100, width:self.view.bounds.width - 40, height: 50))
searchBar.showsCancelButton = false
searchBar.delegate = self
searchBar.placeholder = "搜你想搜的"
searchBar.searchBarStyle = .minimal
searchBar.keyboardAppearance = .light
searchBar.tintColor = .blue
searchBar.layer.cornerRadius = 8
searchBar.layer.masksToBounds = true
self.view.addSubview(searchBar)
END.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)