Ready to Level-Up?

This just in! If your rusty iOS skills could use some refining, or if you're just starting out and you want to level-up fast, consider signing up for our upcoming iOS Screencasts

New from iOS Rocket Surgery Swift Video Tutorials: The rapidly evolving Apple-iOS ecosystem has just been thrown into tumult with the recent introduction of the Swift Programming Language. Are you ready to finally try iOS development? Are you needing to switch from Objective-C to Swift? Sign up today for our free video courses!
(By the dear folks at Swift Tutorial Videos, a sister company)

Tuesday, October 16, 2012

Settting a Background Image on a UIView in iOS

How to Set the Background Image of a UIView

// Oddly, we set the background to be a color, with the image applied as a pattern
UIColor *bg= [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"myimg.png"]];

// Then we just set the background to be our new color on whatever UIView we want to.
// Here, I am assuming you are inside of a UIView
self.view.backgroundColor = bg;

Note: If you're getting a black background image instead of the image you expected, then check to make sure that you've added the image file to your project, and didn't just copy to the project folder on the filesystem. Use "Add File to ___ ..." to include the image in your project.

About Me

Easy NSDateFormatter Tool

Save yourself some time in formatting your NSDates to NSStrings, and use the Blind NSDate app, which you can download from iTunes. There's also a website where you can format your NSDates:

Popular Posts

Designed By Seo Blogger Templates