iOS   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 不兼容的指针类型将类型为’float [2]’的可保留参数传递给CF函数,期望’const CGFloat *'(又名’const double *’)类型大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我收到这个错误,我在arm64下编译出现了这个错误: CGContextSetLineDash(line, 0, lengths, 1); //画虚线 我该如何解决这个问题? - (id)initDashLineWithFrame:(CGRect)frame{ UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:fram
@H_618_14@
@H_618_14@
我收到这个错误,我在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};

应该解决问题.

@H_618_14@

大佬总结

以上是大佬教程为你收集整理的ios – 不兼容的指针类型将类型为’float [2]’的可保留参数传递给CF函数,期望’const CGFloat *'(又名’const double *’)类型全部内容,希望文章能够帮你解决ios – 不兼容的指针类型将类型为’float [2]’的可保留参数传递给CF函数,期望’const CGFloat *'(又名’const double *’)类型所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:cfcgfloatconstdoublefloatios不兼容传递保留函数参数又名指针期望类型
猜你在找的iOS相关文章
其他相关热搜词更多
phpJavaPython程序员load如何string使用参数jquery开发安装listlinuxiosandroid工具javascriptcap