Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在单元格内绘制点UIImageView';UIS图像_Iphone_Ios_Objective C_Uiimage_Cgcontext - Fatal编程技术网

Iphone 在单元格内绘制点UIImageView';UIS图像

Iphone 在单元格内绘制点UIImageView';UIS图像,iphone,ios,objective-c,uiimage,cgcontext,Iphone,Ios,Objective C,Uiimage,Cgcontext,目前,我正在尝试在单元格的UIImageView的UIImage中绘制一个简单的点。我试图实现iPhone的日历应用程序在事件由日历表示时所具有的功能 [[event calendar] CGColor] 是一个EKEvent对象,它记录UIDeviceRbColorSpace 0.509804 0.584314 0.686275 1 我试图创建一个颜色为[[event calendar]CGColor]的小点。以下是我目前正在尝试做的事情: CGContextRef contextRef

目前,我正在尝试在单元格的
UIImageView
UIImage
中绘制一个简单的点。我试图实现iPhone的日历应用程序在事件由日历表示时所具有的功能

[[event calendar] CGColor] 
是一个
EKEvent
对象,它记录
UIDeviceRbColorSpace 0.509804 0.584314 0.686275 1

我试图创建一个颜色为
[[event calendar]CGColor]
的小点。以下是我目前正在尝试做的事情:

CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(contextRef, [[event calendar] CGColor]);
CGContextAddEllipseInRect(contextRef,(CGRectMake (12.f, 5.f, 4.f, 5.f)));
CGContextDrawPath(contextRef, kCGPathFill);
CGContextStrokePath(contextRef);
cell.imageViewPic.image = UIGraphicsGetImageFromCurrentImageContext();
但以下是我得到的错误:

 MYSCHEDULER[21445] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
 MYSCHEDULER[21445] <Error>: CGContextAddEllipseInRect: invalid context 0x0
 MYSCHEDULER[21445] <Error>: CGContextDrawPath: invalid context 0x0
 MYSCHEDULER[21445] <Error>: CGContextDrawPath: invalid context 0x0
MYSCHEDULER[21445]:CGContextSetFillColorWithColor:无效上下文0x0 MYSCHEDULER[21445]:CGContextAddEllipseInRect:无效上下文0x0 MYSCHEDULER[21445]:CGContextDrawPath:上下文0x0无效 MYSCHEDULER[21445]:CGContextDrawPath:上下文0x0无效
我不明白我做错了什么。。。为什么上下文无效?

如我所见,您正在尝试获取所做图形的图像,然后将其添加到imageViewPic。以下是让它工作的方法:

UIGraphicsBeginImageContext(CGSizeMake(5.0f,5.0f)); 
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(contextRef, [[event calendar] CGColor]);
CGContextFillEllipseInRect(contextRef,(CGRectMake (0.f, 0.f, 5.f, 5.f)));
UIImage *drawingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

cell.imageViewPic.image = drawingImage;

UIGraphicsBeginImageContext();给我一个错误。“函数调用的参数太少,未指定单个参数‘size’”我忘记在第一行添加大小。现在它可以工作了。请检查我的编辑。是的,我只是查了一下并添加了单元格的大小imageViewPic。。。谢谢@CODENAMELAMBDA1你真是棒极了!谢谢你的赏识!:)