Changwei
Changwei

Reputation: 672

Why Rectangle drew on UIView is blurry but adding layers to UIView is not when zoom up the UIView?

I am always thinking of this question.

My case is that I need to show many grids on view, I have two plans.

1, draw a lot of rectangles on UIView. I tried it, but when I zoomed up the view, the line is blurry.

2, add a lot of CALayer to UIView. I tried this too, it makes sense, but I don't know if this way will need more memory than way #1.

Please answer me if I can make it not blurry if I use the way #1, thanks.

Upvotes: 0

Views: 59

Answers (1)

Shamas S
Shamas S

Reputation: 7549

A hacky way would be something like this.

Your UIView must have a minimum and maximum zoom. You should create your view with max zoom frame, do the drawing, and scale down and add to the view.

Now when you zoom in, it will go to its 1.0 scale, and the lines won't be blurry.

A non hacky way would be to do the drawing every time the zoom changes.

Upvotes: 1

Related Questions