设置UIActivityIndi​​catorView的框架

发布于 12-09 04:31 字数 102 浏览 4 评论 0原文

我的活动指示器有问题... 如果我设置了指示器的框架,则显示 UIActivity 指示器后面的黑色背景。如果我没有设置框架,它看起来很好,但位置不正确。现在我如何将指示器设置到正确的位置?

I have problem with Activity Indicator…
if i am set the frame of Indicator is show the black background behind UIActivity indicator. and if i not set frame its look well but not in proper position. now how can i set Indicator to proper position?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗琴音2024-12-16 04:31:39

它与这段代码配合得很好。

activityIndicator=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

[activityIndicator setCenter:CGPointMake(w/2-5,w/2-5)];

[activityIndicator setContentMode:UIViewContentModeCenter];

[activityIndicator startAnimating];
[self addSubview:activityIndicator];

Its work well with this code..

activityIndicator=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

[activityIndicator setCenter:CGPointMake(w/2-5,w/2-5)];

[activityIndicator setContentMode:UIViewContentModeCenter];

[activityIndicator startAnimating];
[self addSubview:activityIndicator];
深海夜未眠2024-12-16 04:31:39

添加到@Raj 答案。
您可以使用绑定属性,而不是计算“w”并将其传递到 CGPointMake 中。

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];
indicator.center = CGPointMake(CGRectGetMidX(yourView.bounds), CGRectGetMidY(yourView.bounds));
[yourView addSubview:indicator];

Addind to @Raj answer.
Rather than calculating 'w' and pasing them in CGPointMake, you can use bound property.

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];
indicator.center = CGPointMake(CGRectGetMidX(yourView.bounds), CGRectGetMidY(yourView.bounds));
[yourView addSubview:indicator];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文