Search code examples
objective-cimagedesign-patternsscalerepeat

objective-c scale background on one axis


hi i have a background pattern image (vertical lines) like:

llllllllllllllllllllllllll

the line is a pattern image:

bgimg.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"pd_line2.png"]];

my problem: i would like to reframe the bgimg - it should repeat the line on x-axis: but stretch the line on y-axis.

next problem: the pattern image also uses an alpha channel.

is this possible? can someone please give me a hint?

thanks in advance


Solution

  • Well you can certainly scale the image in various ways via GCContext functions, but perhaps the easier way would be making your view transparent (clearColor background) and adding an extra UIImageView (with pd_line2.png in it) underneath. UIImageView's built-in stretching options may be enough to achieve what you need without any coding.