KieranLafferty / KLSwitch

An iOS 7 UISwitch clone that works on iOS 5+
Other
263 stars 49 forks source link

Improvements to solve laggy scroll performance in older devices. #16

Closed manuyavuz closed 8 years ago

manuyavuz commented 10 years ago

If we use KLSwitch views in UITableViewCells, scroll performance of table view degrades and becomes laggy.

The reason is that KLSwitch sets "cornerRadius" property, and this results in performance hit when drawing layers.

To solve this, we masksToBounds to yes on related layers, so that drawing system does not try to apply rounded masks to view. Also we set shouldRasterize property to YES to draw view as a bitmap and cache it. (Details can be found in the documentation.)

This setup gives back the tableview it's smooth scroll performance.