ios - What is the best practice for creating custom UIView's? -
for creating custom views have 3 options.
override
func drawrect(_ rect: cgrect)
add sub-layers view's layer.
do both.
what best practice? why override drawrect if can draw in sub-layer (with easier api)?
thanks
rendering in drawrect
means using cpu draw view using core graphics.
if can use composition of calayer
sub-layers, better option heavy lifting done gpu.
on top of that, drawrect
called on main thread, , if drawing code isn't fast app less responsive (of course can use background thread solve problem, still using cpu draw bitmap).
Comments
Post a Comment