Solved

iPhone app development: Can I programmatically change the screen brightness?

Posted on 2009-05-08
4
3,260 Views
Last Modified: 2012-05-06
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?
0
Comment
Question by:ehensens
  • 2
4 Comments
 

Expert Comment

by:allentheg
ID: 24339234
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.
0
 

Author Comment

by:ehensens
ID: 24339251
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.
0
 
LVL 8

Accepted Solution

by:
inbox788 earned 500 total points
ID: 24339405
0
 

Expert Comment

by:allentheg
ID: 24339406

-(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];
}

Open in new window

0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is a security feature on iOS devices that is nearly impenetrable when it has been activated.  This article will provide some possible solutions as well as necessary steps to take to ensure you do not end up with a locked device.
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question