iOS: UIActivityIndicator in UISearchBar

ios, search, uiactivityindicatorview, uisearchbar, xcode

Solution

Yes you can.

When start searching create an activity indicator and add it as the subview of `UISearchBar` using `addSubView` method. When you finish the search remove it from the search bar using `removeFromSuperView` method.

UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
//set frame for activity indicator
[searchBar addSubview: spinner];
[spinner startAnimating];

Refer this link for an alternative way.

Problem

Is it possible to display an UIActivityIndicator in the UISearchBar while searching?

Original source

Related problems