UIActivityIndicatorView inside UIButton

自作多情 提交于 2019-12-11 11:13:28

问题


I have a couple of programmatically generated UIButtons (custom, 200 by 200, white background) where i wanted to put a UIActivityIndicatorView inside. I tried it with the following code:

UIActivityIndicatorView *playlistImageLoader = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
playlistImageLoader.center = CGPointMake(100, 100);
playlistImageLoader.hidesWhenStopped = YES;

[playlistImage addSubview:playlistImageLoader];
[mainScrollView addSubview:playlistImage];

[playlistImageLoader startAnimating];

But it doesn't show up? Have any ideas?

thanks!


回答1:


You didn't set the indicator frame, set it and it will be alright to have it as a button subview.

Try to use UIActivityIndicatorViewStyleGray - UIActivityIndicatorViewStyleWhite is invisible on the white background.



来源:https://stackoverflow.com/questions/12360259/uiactivityindicatorview-inside-uibutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!