1

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

Alex Milde
  • 511
  • 1
  • 7
  • 21

1 Answers1

0

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.

SVD
  • 4,743
  • 2
  • 26
  • 38
  • but the view has to repeat on x-axis.isnt adding ca 100 uiimageviews on x axis a huge waste of resources? – Alex Milde Apr 11 '11 at 15:50
  • You'll need just _one_ UIImageView that spans across the whole window. – SVD Apr 11 '11 at 16:12
  • maybe you can provide some code. i cant find a method to repat the image on x axis in the uiimageview – Alex Milde Apr 11 '11 at 16:29
  • You are perfectly right - I guess I was mistaking the Interface Builder with something else. No image repeating options there. Then you really need to scale the image so that it is stretched across the window and use that new image for tiling. There are plenty of examples regarding scaling, e.g. http://stackoverflow.com/questions/2645768/uiimage-resize-scale-proportion – SVD Apr 11 '11 at 16:55
  • found that example aswell - BUT - my image has an alpha channel - and i couldnt find a solution for stretching the image WITH the alpha channel. – Alex Milde Apr 11 '11 at 16:56
  • Then perhaps you need to have a separate mask image that you'd stretch in the same fashion as your original image, and them mask it with the stretched mask. Or maybe it will be easier to somehow get an already stretched image - luckily there isn't much variation in iPhone screen sizes. – SVD Apr 11 '11 at 17:10
  • i think i need the stretch mask thing. the height is dynamic - so i have to create the mask at runtime. – Alex Milde Apr 11 '11 at 17:20