I'm making simple number coloring game (like sandbox, pixel art, unicorn, etc) and came across a problem. I tried various methods of filling rects in the screen.
At first i created a backgroundView(a simple UIView) which had 2500 subviews(also UIViews), each one had
size = (CGSize){50,50}
. Added a tap gesture recognizer, detected which view should be filled, and simply changed the background color of that view. But when i placed the backgroundView in the scrollView, the scroll and zooming were awful.Tried same thing but this time each rectangle was a
CALayer
. So a backgroundView, which had 2500 sublayers(each was aCALayer
with 50,50 size) - zoom and scroll was also awful.Tired to use custom drawing with overriding drawRect method in UIView subclass or
drawInContext
inCALayer
subclass(i was filling rects withCGContext
), this time problem was also caused by the zooming and scrolling. Because i needed to update every rect when user zooms, it was triggering a lot of drawRect calls, and performance was also bad.
Any thoughts how can i fill rects in the screen ?