1wyoeg
Last Updated: February 25, 2016
·
2.063K
· yorirou

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

352

Why not use UIView.backgroundColor?

over 1 year ago ·
12520

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 ·