ehensens
asked on
iPhone app development: Can I programmatically change the screen brightness?
Hi all,
So I just added a UIActivityIndicator to my app. It works fine but it's not very flashy and there's not always a great place for it on the screen. So, what I would like to do is to make the entire screen much darker and then put the activity indicator right in the middle, as I know I've seen that elsewhere.
Does anyone know of a way to do this?
Thanks for any suggestions?
So I just added a UIActivityIndicator to my app. It works fine but it's not very flashy and there's not always a great place for it on the screen. So, what I would like to do is to make the entire screen much darker and then put the activity indicator right in the middle, as I know I've seen that elsewhere.
Does anyone know of a way to do this?
Thanks for any suggestions?
You can do this easily by using the interface builder. Double-click on the .xib file that you are working on, and the interface builder will load up. From there, you will see a white rectangle. This is where you can items into your iphone app and it will show up when you run it. You can change the background of the view to a darker color. You can also drag and drop your UIActivityIndicator into the middle of your interface.
ASKER
The problem is I need to change this from my code, it needs to go darker when I load up the indicator and then back to normal when the indicator is turned off.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
-(void)hideActivityViewer
{
[[[activityView subviews] objectAtIndex:0] stopAnimating];
[activityView removeFromSuperview];
activityView = nil;
}
-(void)showActivityViewer
{
[activityView release];
activityView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, window.bounds.size.width, window.bounds.size.height)];
activityView.backgroundColor = [UIColor blackColor];
activityView.alpha = 0.5;
UIActivityIndicatorView *activityWheel = [[UIActivityIndicatorView alloc] initWithFrame: CGRectMake(window.bounds.size.width / 2 - 12, window.bounds.size.height / 2 - 12, 24, 24)];
activityWheel.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
activityWheel.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
[activityView addSubview:activityWheel];
[activityWheel release];
[window addSubview: activityView];
[activityView release];
[[[activityView subviews] objectAtIndex:0] startAnimating];
}