This is rough translation to Swift…no tested.
// Define some colors.
var darkGray: UIColor = UIColor.darkGrayColor()
var lightGray: UIColor = UIColor.lightGrayColor()
// Navigation bar background.
UINavigationBar.appearance().barTintColor = darkGray
UINavigationBar.appearance().tintColor = lightGray
// Color of typed text in the search bar.
var searchBarTextAttributes: [NSObject : AnyObject] = [NSForegroundColorAttributeName: lightGray, NSFontAttributeName: UIFont.systemFontOfSize(UIFont.systemFontSize())]
UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).defaultTextAttributes = searchBarTextAttributes
// Color of the placeholder text in the search bar prior to text entry.
var placeholderAttributes: [NSObject : AnyObject] = [NSForegroundColorAttributeName: lightGray, NSFontAttributeName: UIFont.systemFontOfSize(UIFont.systemFontSize())]
// Color of the default search text.
// NOTE: In a production scenario, "Search" would be a localized string.
var attributedPlaceholder: NSAttributedString = NSAttributedString(string: "Search", attributes: placeholderAttributes)
UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).attributedPlaceholder = attributedPlaceholder
2
solved Add objective c code to swift file [closed]