Cropping center square of UIImage

后端 未结 18 618
日久生厌
日久生厌 2020-12-07 23:09

So here\'s where I\'ve made it so far. I am using a UIImage captured from the camera and can crop the center square when in landscape. For some reason this doesn\'t transl

18条回答
  •  轮回少年
    2020-12-07 23:34

    I was able to accomplish it with something like this:

       UIImage *thisImage = [[UIImage alloc] initWithContentsOfFile:imagePath];
                    double x = (thisImage.size.width )/2.0;
                    double y = (thisImage.size.height)/2.0;
                    mediaImage = [self imageByCropping:thisImage toRect:CGRectMake(x, y, 60, 60)];
                    [thisImage release];
    

提交回复
热议问题