I am working on drawing custom buttons/textfields with NSDrawNinePartImage
. I slice up an image into nine parts in code and draw it into a rect with NSDrawNinePartImage
.
Unfortunately I am getting some gaps in the drawing pattern. I thought it had something to do with my slicing code, but I saved them out as images from where I slice them, and they all look good (I even put them together and they looked good). Some of the cases where I use it to work just fine though despite some using the same images.
I am pretty confident that it comes down to the actual drawing.
Do you know of any NSGraphicsContext
or other settings that would affect it or something else that may be causing this?
With gaps
Without gaps
I fixed a similar issue by disable the anti-alias option
NSGraphicsContext* theContext = [NSGraphicsContext currentContext];
[theContext saveGraphicsState];
[theContext setShouldAntialias: NO];
NSDrawNinePartImage(...);
[theContext restoreGraphicsState];
Is it possible that your upper left and lower right images are a pixel too wide?
This function uses the top-left and bottom-right corner images to determine the widths and heights of the edge areas that need to be filled. If the width or height of the bottom-left and top-right images are not sized appropriately, they may be scaled to fill their corner area. Edge areas between the corners are tiled using the corresponding image. Similarly, the center area is tiled using the specified center image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With