adi*_*dit 7 iphone objective-c ipad ios
我有一个drawRect,我想填写用某种颜色指定的矩形.我该怎么办?到目前为止,我尝试了以下内容:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor colorWithWhite:29/255.f alpha:1.0].CGColor);
CGContextFillRect(context, rect);
}
Run Code Online (Sandbox Code Playgroud)
这似乎不起作用
bor*_*den 26
[[UIColor colorWithWhite:29/255.f alpha:1.0] setFill];
UIRectFill(rect);
Run Code Online (Sandbox Code Playgroud)
这是最简单的方法