Last Updated: September 09, 2019
·
2.391K
· tamasd

Filling a UIView with one color.

Don't do it with UIBezierPath, because it's slow.

A much faster way:

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetRGBFillColor(context, 0.f, 0.f, 0.f, 1.f);
CGContextFillRect(context, [self bounds]);

2 Responses
Add your response

Why not use UIView.backgroundColor?

over 1 year ago ·

freerunnering, because it might be changed by UIKit, for example, if a view is in UITableViewCell, and when that cell gets selected - UIKit will set all that's cell subviews' background color to cell selected color.

over 1 year ago ·