Developer
Developer

Reputation: 6465

How to have a smooth edges after rotating the UIView

I am rotating a view by some angle by after rotating I am not getting the smooth edge of the view. Please check the attached image. Is there any way to have a smooth edge of UIView?

I have used the following statement for this purpose.

CGContextRotateCTM(currentContext, RADIANS(-5));

enter image description here

Upvotes: 0

Views: 921

Answers (3)

Eike
Eike

Reputation: 2431

It helps a lot if you set shouldRasterize = true for the layer of your view.

yourView.layer.shouldRasterize = true

When the value of this property is true, the layer is rendered as a bitmap in its local coordinate space and then composited to the destination with any other content. Shadow effects and any filters in the filters property are rasterized and included in the bitmap. However, the current opacity of the layer is not rasterized. If the rasterized bitmap requires scaling during compositing, the filters in the minificationFilter and magnificationFilter properties are applied as needed.

Upvotes: 2

Ashim
Ashim

Reputation: 286

set 1 pixel transparent border. This will helps you magically.

Upvotes: 0

ian
ian

Reputation: 15881

Try enabling anti-aliasing before rotating:

CGContextSetShouldAntialias(currentContext, true);

Upvotes: 0

Related Questions