I am new to iPhone development. I want to set an activity indicator which is loaded on my custom button. Please guide me. (Example: App store --> Search --> Show 25 more (on click)).
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Add the UIActivityIndicatorView
as a subview of the button:
// Create spinner
UIActivityIndicatorView *myIndicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
// Position the spinner
[myIndicator setCenter:CGPointMake(myButton.frame.size.width / 2, myButton.frame.size.height / 2)];
// Add to button
[myButton addSubview:myIndicator];
// Start the animation
[myIndicator startAnimating];