4

このエラーが発生しています。arm64 でコンパイルすると、次のエラーが表示されます。

CGContextSetLineDash(line, 0, lengths, 1);  //画虚线

これを解決するにはどうすればよいですか?

- (id)initDashLineWithFrame:(CGRect)frame{
    UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:frame];

    UIGraphicsBeginImageContext(imageView1.frame.size);   //开始画线
    [imageView1.image drawInRect:CGRectMake(0, 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, 156, 1);
    CGContextSetStrokeColorWithColor(line, coloreline.CGColor);

    CGContextSetLineDash(line, 0, lengths, 1);  //画虚线
    CGContextMoveToPoint(line, 0.0, 5.0);    //开始画线
    CGContextAddLineToPoint(line, 310.0, 5.0);
    CGContextStrokePath(line);

    imageView1.image = UIGraphicsGetImageFromCurrentImageContext();
    return imageView1;
}
4

1 に答える 1

20

64 ビット アーキテクチャ (arm64 など) では、CGFloatは として定義されdoubleているため、8 バイトの浮動小数点数floatですが、 は 4 バイトの浮動小数点数です。float[]したがって、配列を期待する関数に配列を渡すことはできませんCGFloat[]

配列をに変更する

CGFloat lengths[] = {4,5};

問題を解決する必要があります。

于 2014-09-11T09:16:29.140 に答える