IOS Tips

From EggeWiki
Revision as of 16:14, 11 February 2012 by Brianegge (talk | contribs) (Created page with "==== Tile a background image in a UIViewController ==== <geshi lang="C"> // tile background UIImage *wave = [UIImage imageNamed:@"background-dots.png"]; CGSize imageVie...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Tile a background image in a UIViewController

<geshi lang="C">

 // tile background
 UIImage *wave = [UIImage imageNamed:@"background-dots.png"];
 CGSize imageViewSize = imageView.bounds.size;
 
 UIGraphicsBeginImageContext(imageViewSize);
 
 CGRect imageRect;
 imageRect.origin = CGPointMake(0.0, 0.0);
 imageRect.size = CGSizeMake(wave.size.width, wave.size.height);
 
 CGContextRef imageContext = UIGraphicsGetCurrentContext();
 CGContextDrawTiledImage(imageContext, imageRect, wave.CGImage);
 
 UIImage *finishedImage = UIGraphicsGetImageFromCurrentImageContext();
 
 UIGraphicsEndImageContext();
 
 imageView.image = finishedImage;

</geshi>