How use CGImageCreateWithImageInRect for iPhone 4 (HD)?

前端 未结 2 1114
不知归路
不知归路 2020-12-14 02:38

I use the following code to getting images from the sprite. And it works fine everywhere except the iPhone 4 (HD version).

- (UIImage *)croppedImage:(CGRect)         


        
2条回答
  •  失恋的感觉
    2020-12-14 03:23

    From what I can tell the CGImageCreateWithImageInRect will do the right thing. What you need to change is the UIImage initilization

    http://developer.apple.com/iphone/library/documentation/uikit/reference/UIImage_Class/Reference/Reference.html#//apple_ref/occ/clm/UIImage/imageWithCGImage:scale:orientation:

    Change it to [UIImage imageWithCGImage:image scale:self.scale orientation:self. imageOrientation] and it should work just fine. (this is assuming this is a category on UIImage which it looks like it is)

提交回复
热议问题