2015-01-06

UIView with background image repeated and stretched

Views: 10411 | Add Comments

You can set the background of an UIView or a subclass of UIView be filled with an image, repeated or stretched.

Repeated

UIImage *img = [UIImage imageNamed:@"bg.png"];
row.backgroundColor = [UIColor colorWithPatternImage:img];

Stretched

UIImage *img = [UIImage imageNamed:@"bg.png"];
row.layer.contents = (id)img.CGImage;
Posted by ideawu at 2015-01-06 14:38:24 Tags:

Leave a Comment