您可以使用UIView 的frame属性绘制矩形.只需将其传递给CGContextFillRect函数(设置上下文填充颜色).
使用当前图形状态中的填充颜色绘制所提供矩形内包含的区域.
所以drawRect中的代码:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext ();
// The color to fill the rectangle (in this case black)
CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0);
// draw the filled rectangle
CGContextFillRect (context, self.bounds);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7213 次 |
| 最近记录: |