YellowPillow
YellowPillow

Reputation: 4270

Is there a way to purposely turn off all anti-aliasing for UIView?

I'm trying to make a kind of old-looking app, and so as a result I want my UIView's to be rendered without anti-aliasing. In other words I want my views to be pixelized ,especially the view.layer.cornerRadius, as in this case I am able to layout my views using AutoLayout.

This would make it much easier than drawing different pixel arts for different iPhone sizes. Moreover, if I did draw the pixel art whenever a view is resized I would have to create a new pixel art as scaling the images vould distort the pixel art.

The only thing that I have found is view.layer.allowsEdgeAntialiasing which by default is already set to false. I was also thinking to use the Core Graphic's BeizerPaths to draw the pixelized shadows and corners, would this be a viable way to achieve what I want?

Upvotes: 4

Views: 1051

Answers (1)

user3230875
user3230875

Reputation: 689

You can go down to the Core Graphics CGContext and friends, and you can specifically tell the Graphics Context to shut off anti-aliasing, with CGContextSetShouldAntialias(context, false);

Here are two small screen grabs, one with no jaggies, and the other with jaggies.

First Image With No Jaggies

Second Image WIth Jaggies

Upvotes: 1

Related Questions