显示活动指示器时使背景变钝?

hem*_*ant 2 iphone iphone-sdk-3.0

恢复一些数据我正在显示一个活动指示器..但我希望背景图像变得暗淡或暗淡一点,以便焦点在活动指示器上..我已经看到在某些应用程序中但是无法弄清楚如何实现这一点??

小智 5

添加黑色或白色子视图(使其大小与背景大小相同),并将子视图的alpha设置为0.5(您可以按照自己喜欢的方式调整),而不是仅添加活动指示器.然后将活动指示器放在此黑色或白色子视图上.希望这是你正在寻找的效果.这是一些示例代码:

DisabledView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
[DisabledView setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.2]];

[self addSubview:DisabledView];

SearchBarIndicator = [[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 25.0f, 25.0f)] autorelease];
[SearchBarIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[SearchBarIndicator setCenter:CGPointMake(160, 160)];
[DisabledView addSubview:SearchBarIndicator];
Run Code Online (Sandbox Code Playgroud)