![ios – 不兼容的指针类型将类型为’float [2]’的可保留参数传递给CF函数,期望’const CGFloat *'(又名’const double *’)类型,第1张 ios – 不兼容的指针类型将类型为’float [2]’的可保留参数传递给CF函数,期望’const CGFloat *'(又名’const double *’)类型,第1张](/aiimages/ios+%E2%80%93+%E4%B8%8D%E5%85%BC%E5%AE%B9%E7%9A%84%E6%8C%87%E9%92%88%E7%B1%BB%E5%9E%8B%E5%B0%86%E7%B1%BB%E5%9E%8B%E4%B8%BA%E2%80%99float+%5B2%5D%E2%80%99%E7%9A%84%E5%8F%AF%E4%BF%9D%E7%95%99%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92%E7%BB%99CF%E5%87%BD%E6%95%B0%2C%E6%9C%9F%E6%9C%9B%E2%80%99const+CGFloat+%2A%26amp%3B%2339%3B%28%E5%8F%88%E5%90%8D%E2%80%99const+double+%2A%E2%80%99%29%E7%B1%BB%E5%9E%8B.png)
CGContextSetlineDash(line,lengths,1); //画虚线
我该如何解决这个问题?
- (ID)initDashlineWithFrame:(CGRect)frame{ UIImageVIEw *imageVIEw1 = [[UIImageVIEw alloc]initWithFrame:frame]; UIGraphicsBeginImageContext(imageVIEw1.frame.size); //开始画线 [imageVIEw1.image drawInRect:CGRectMake(0,imageVIEw1.frame.size.wIDth,imageVIEw1.frame.size.height)]; CGContextSetlineCap(UIGraphicsGetCurrentContext(),kCGlineCapRound); //设置线条终点形状 float lengths[] = {4,5}; CGContextRef line = UIGraphicsGetCurrentContext(); UIcolor *coloreline = [UIcolor colorWithRed:156/255.0 green:156/255.0 blue:156/255.0 Alpha:1];//r(156,156,1); CGContextSetstrokecolorWithcolor(line,coloreline.CGcolor); CGContextSetlineDash(line,1); //画虚线 CGContextMovetoPoint(line,0.0,5.0); //开始画线 CGContextAddlinetoPoint(line,310.0,5.0); CGContextstrokePath(line); imageVIEw1.image = UIGraphicsGetimageFromCurrentimageContext(); return imageVIEw1;}解决方法 在64位体系结构(如arm64)上,CGfloat被定义为double,因此是a 8字节浮点数,而float是4字节浮点数.因此,您无法传递float []数组
期望CGfloat []数组的函数.
将阵列更改为
CGfloat lengths[] = {4,5}; 应该解决问题.
总结以上是内存溢出为你收集整理的ios – 不兼容的指针类型将类型为’float [2]’的可保留参数传递给CF函数,期望’const CGFloat *'(又名’const double *’)类型全部内容,希望文章能够帮你解决ios – 不兼容的指针类型将类型为’float [2]’的可保留参数传递给CF函数,期望’const CGFloat *'(又名’const double *’)类型所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)