当前位置 : 主页 > 手机开发 > ios >

ios – 在Swift中调用CGPatternCreate

来源:互联网 收集:自由互联 发布时间:2021-06-11
我想知道如何将以下 objective-c方法转换为 Swift函数? CGPatternRef pattern = CGPatternCreate(NULL, rect, CGAffineTransformIdentity, 24, 24, kCGPatternTilingConstantSpacing, true, callbacks); 我的代码: let callbacks : C
我想知道如何将以下 objective-c方法转换为 Swift函数?

CGPatternRef pattern = CGPatternCreate(NULL,
                                       rect,
                                       CGAffineTransformIdentity,
                                       24,
                                       24,
                                       kCGPatternTilingConstantSpacing,
                                       true,
                                       &callbacks);

我的代码:

let callbacks : CGPatternCallbacks = CGPatternCallbacks(version: 0)

    let pattern : CGPatternRef = CGPatternCreate(nil,
        rect,
        CGAffineTransformIdentity,
        24,
        24,
        kCGPatternTilingConstantSpacing,
        true,
        callbacks)

但是我收到了一条错误消息:

‘CGPatternCallbacks’ is not convertible to ‘CConstPointer’

有没有示例代码?谢谢

这样的事情

var callbacks : CGPatternCallbacks = CGPatternCallbacks(version: 0)

var pattern = CGPatternCreate(nil,
    rect,
    CGAffineTransformIdentity,
    24,
    24,
    kCGPatternTilingConstantSpacing,
    true,
    &callbacks)
网友评论