ios – 不兼容的指针类型将类型为’float [2]’的可保留参数传递
发布时间:2020-12-14 17:17:47 所属栏目:百科 来源:网络整理
导读:我收到这个错误,我在arm64下编译出现了这个错误: CGContextSetLineDash(line,lengths,1); //画虚线 我该如何解决这个问题? - (id)initDashLineWithFrame:(CGRect)frame{ UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:frame]; UIGraphicsB
我收到这个错误,我在arm64下编译出现了这个错误:
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}; 应该解决问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |