Search code examples
iosobjective-cuicolorcashapelayer

UIColor colorWithPatternImage with increasing offset


I am asynchronously downloading a list of square images where each of them represents some color or pattern.

Let's say for example this square (even though you'll see only a triangle, the other part is white):

pattern image

My goal is to make these images round and clickable so I am using a private library MCColorPicker which expects an array of UIColor and then for each element of this array creates a new subclass of CAShapeLayer class. New UIColor for downloaded image is created with colorWithPatternImage

convertedColor = [UIColor colorWithPatternImage:image];

The problem is that each subsequent UIColor image has an offset from the previous one and only the first few ones fit in the circle.

enter image description here

I cannot understand why do they move for a few points for each new color. Do you have and idea where could be a problem?

Thanks.


Solution

  • Finally I've solved this issue with this SO answer. It was necessary to fit the images in the center as they were drawn one after other one.