2010-05-26 34 views
2

同時恢復一些數據,我正在顯示indicator..but我想要的背景圖像變得遲鈍或變暗有點活動,以便重點是活動indicator..i已經看到,在某些應用中,但無法弄清楚如何實現那個?在顯示活動指示符時使背景變暗?

回答

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]; 
2

看看MBProgressHUD這是對其他視圖上面顯示各種活動指標的開源框架。