开发者

Scale UIImageView relatively

I've got two UIImageViews, I've managed to merge and save them. But I want the overlaying image to scale and position relatively with the scale of the chosen image. So that the UIImageView that you see on the screen looks the same as the UIImageView which it saves.

- (UIImage *)combineImages{

UIGraphicsBeginImageContext(CGSizeMake(theimageView.image.size.width,theimageView.image.size.height));

// Draw image1
[theimageView.image drawInRect:CGRectMake(0,0, theimageView.image.size.width,theimageView.image.size.height)];

// Draw image2
[Birdie.image drawInRect:CGRectMake(Birdie.center.x, Birdie.center.y, (theimageView.image.size.width / 2), (theimageView.image.size.height / 2))];

UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphi开发者_JAVA百科csEndImageContext();

return resultingImage;

}

theImageView and Birdie are the two UIImageViews. Thanks in advanced!


Please Try this,

  - (UIImage *)combineImages{



    // Draw image1
    [theimageView.image drawInRect:CGRectMake(0,0, theimageView.image.size.width,theimageView.image.size.height)];

    // Draw image2
    [Birdie.image drawInRect:CGRectMake(Birdie.frame.origin.x, Birdie.frame.origin.y, Birdie.frame.size.width, Birdie.frame.size.height)];
    //have you added Birdie over theimageView if not than do this. If your size is already set as you want then there is no need for above two lines of drawInRect.
    UIGraphicsBeginImageContext(theimageView.bounds.size);
    [theimageView.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return resultingImage;
    }

Thanks,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜