1

我怎样才能CGAffineTransformNSStringCocoa 中获得一个?

在 iOS 上有CGAffineTransformFromString.

4

1 回答 1

2

由于缺乏更好的解决方案,我目前正在这样做:

CGAffineTransform CGAffineTransformFromString(NSString *string)
{
    string = [string stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"[ ]"]];
    NSArray *components = [string componentsSeparatedByString:@","];
    CGAffineTransform transform;
    transform.a = [[components objectAtIndex:0] floatValue];
    transform.b = [[components objectAtIndex:1] floatValue];
    transform.c = [[components objectAtIndex:2] floatValue];
    transform.d = [[components objectAtIndex:3] floatValue];
    transform.tx = [[components objectAtIndex:4] floatValue];
    transform.ty = [[components objectAtIndex:5] floatValue];
    return transform;
}
于 2012-10-18T10:42:26.297 回答