gpt4 book ai didi

iphone - 在 iOS 的 UIView 上加载时如何为 UIActivityIndi​​cator 设置灰色背景

转载 作者:技术小花猫 更新时间:2023-10-29 10:54:59 25 4
gpt4 key购买 nike

我目前有一个 UIActivityIndi​​cator 出现在屏幕上一两秒钟。我想将背景设置为灰色,因为它出现在屏幕上,但我不知道该怎么做...

到目前为止,这是我初始化指标的方式。

- (void)viewDidLoad
{
//...

activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
[activity setCenter:CGPointMake(160.0f, 208.0f)];
[activity setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];

[self.tableView addSubview:activity];

[activity startAnimating];

[activity performSelector:@selector(stopAnimating) withObject:nil afterDelay:1.0];


}

如有任何帮助,我们将不胜感激。

最佳答案

不需要单独的 View 。这是一个简单的机制:

    UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

self.activityIndicatorView = activity;
// make the area larger
[activity setFrame:self.view.frame;
// set a background color
[activity.layer setBackgroundColor:[[UIColor colorWithWhite: 0.0 alpha:0.30] CGColor]];
CGPoint center = self.view.center;
activity.center = center;
[activity release];

关于iphone - 在 iOS 的 UIView 上加载时如何为 UIActivityIndi​​cator 设置灰色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8002205/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com