1

我正在寻找创建以下字典的方法

    NSDictionary *frameProperties = [NSDictionary dictionaryWithObject:[NSDictionary 
                                                  dictionaryWithObject:[NSNumber numberWithInt:2] 
                                                                forKey:(NSString *) kCGImagePropertyGIFDelayTime]
                                     forKey:(NSString *) kCGImagePropertyGIFDictionary];

通过CoreFoundation,即与CFDictionaryCreate

任何想法如何实现这一点?

4

1 回答 1

3

似乎我已经自己构建了答案,请确认某人。代码编译正常,但我还不能测试它。

    int delayOnEachFrame = 2;
    const void *tkeys[1] = { kCGImagePropertyGIFDelayTime };
    const void *tvalues[1] = { CFNumberCreate(0, kCFNumberSInt32Type, &delayOnEachFrame) };
    CFDictionaryRef tframeProperties = CFDictionaryCreate(NULL, tkeys, tvalues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);

    const void *keys[1] = { kCGImagePropertyGIFDictionary };
    const void *values[1] = { tframeProperties };
    CFDictionaryRef frameProperties = CFDictionaryCreate(NULL, keys, values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
于 2012-06-10T14:53:55.217 回答