jab*_*jab 2 cocoa-touch avfoundation drawrect ios
我在故事板上有一个ViewController.我使用界面构建器在屏幕底部设置工具栏.我已将自定义视图设置为视图覆盖drawRect.然而,对于我的生活,我无法在从drawRect调用的屏幕上显示任何内容.drawRect本身被称为正常,但没有任何东西出现在屏幕上.
此外,我有一个ViewController,其方法使用AVCaptureSession将其背景切换为来自摄像头输入的实时视图.我曾怀疑这可能是导致错误的原因,但在删除AVCaptureSession的所有引用后,我仍然无法使其工作.
对不起我的写作和/或缺乏逻辑,我现在没有任何睡眠.
编辑:这是一个不起作用的代码的小例子.内部的每个方法都被调用,但没有任何东西可以显示.
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
// Draw them with a 2.0 stroke width so they are a bit more visible.
CGContextSetLineWidth(context, 2.0);
CGContextMoveToPoint(context, 0,0); //start at this point
CGContextAddLineToPoint(context, 100, 100); //draw to this point
// and now draw the Path!
CGContextStrokePath(context);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1804 次 |
| 最近记录: |