Spaces NSDrawNinePartImage

I am working on drawing custom buttons / text fields using NSDrawNinePartImage . I slice the image into nine pieces of code and draw it into a rectangle using NSDrawNinePartImage .

Unfortunately, I get some spaces in the drawing template. I thought this was due to my cutting codec, but I saved them in the form of images from which I cut them, and they all look good (I even put them together and they looked good). Some of the cases when I use it to work just fine, even though some use the same images.

I am pretty sure that it comes down to the actual drawing.

Are you aware of any NSGraphicsContext or other settings that will affect it or anything else that might cause this?

With spaces

With gaps

Without spaces

Without gaps

+6
source share
3 answers

I fixed a similar problem by disabling the anti-alias option

 NSGraphicsContext* theContext = [NSGraphicsContext currentContext]; [theContext saveGraphicsState]; [theContext setShouldAntialias: NO]; NSDrawNinePartImage(...); [theContext restoreGraphicsState]; 
+4
source

Is it possible that your upper left and lower right images are too wide?

This function uses the upper and lower right corner images to determine the width and height of the edge areas to be filled. If the width or height of the lower and upper right images are not of the proper size, they can be scaled to fill their corner area. The border areas between the corners are tiled using an appropriate image. Similarly, the central region is tiled using the indicated center image.

+1
source

Use even image sizes. I did this and he solved this problem for me.

0
source

Source: https://habr.com/ru/post/889778/


All Articles