for item in searchBar.subviews[0].subviews{ ifitem.isKind(of:UIImageView.self){ item .removeFromSuperview() } }