Iphone 如何使用矩形裁剪图像?

Iphone 如何使用矩形裁剪图像?,iphone,ios,image-processing,uiimageview,uiimage,Iphone,Ios,Image Processing,Uiimageview,Uiimage,我正在尝试使用此矩形裁剪图像。但不知道如何拉伸矩形。我有一个ui视图,它位于另一个视图的外部和内部,显示为黑色边框。拉伸时是否需要同时更改UIViews 应使用Pinchgesture拉伸矩形或任何其他方法 这里有四个蓝色处理程序UIViews。我将如何确定它们的拖动?? 如果有,请建议。以下代码用于选择框和裁剪图像 -(IBAction) cropImage:(id) sender{ // Create rectangle that represents a cropped image

我正在尝试使用此矩形裁剪图像。但不知道如何拉伸矩形。我有一个
ui视图
,它位于另一个视图的外部和内部,显示为
黑色边框
。拉伸时是否需要同时更改
UIView
s

应使用
Pinchgesture
拉伸矩形或任何其他方法

这里有四个蓝色处理程序
UIView
s。我将如何确定它们的拖动??
如果有,请建议。

以下代码用于选择框和裁剪图像

-(IBAction) cropImage:(id) sender{
    // Create rectangle that represents a cropped image  
    // from the middle of the existing image
float xCo,yCo;
float width=bottomCornerPoint.x-topCornerPoint.x;
float height=bottomCornerPoint.y-topCornerPoint.y;
if(width<0)
width=-width;
if(height<0)
    height=-height;
         if(topCornerPoint.x <bottomCornerPoint.x)
         {
               xCo=topCornerPoint.x;
          }
         else 
         {
             xCo=bottomCornerPoint.x;
         } 
        if(topCornerPoint.y <bottomCornerPoint.y)
        {
             yCo=topCornerPoint.y;
         }
      else {
             yCo=bottomCornerPoint.y;
       }
    CGRect rect = CGRectMake(xCo,yCo,width,height);
    // Create bitmap image from original image data,
    // using rectangle to specify desired crop area
    UIImage *image = [UIImage imageNamed:@"abc.png"];
    CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], rect);
    UIImage *img = [UIImage imageWithCGImage:imageRef]; 
    CGImageRelease(imageRef);
    // Create and show the new image from bitmap data
    imageView = [[UIImageView alloc] initWithImage:img];
    [imageView setFrame:CGRectMake(110, 600, width, height)];
    imageView.image=img;
    [[self view] addSubview:imageView];
    [imageView release];
}
-(iAction)cropImage:(id)发件人{
//创建表示裁剪图像的矩形
//从现有图像的中间
浮动xCo,yCo;
浮动宽度=底部角点.x-顶部角点.x;
浮动高度=底部角点.y-顶部角点.y;

如果(宽度我没有这样做,但这里有一些可能对你有用的链接。:,检查这个链接,它包含你想要的:@Devang我已经为它创建了矩形。只需拖动它,SetbjiMageCroper就会给你一些想法。它包含拖动功能。你需要指定一个cropView并向它添加手势以调整大小把它洗干净