iPhone:在Image的透明部分设置imageView [英] iPhone:Set imageView in transparent portion of the Image

查看:51
本文介绍了iPhone:在Image的透明部分设置imageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个应用程序,其中允许用户首先选择一个相框,然后他/她必须从图库中为该相框选择2张照片(相框是在其上包含两个透明孔的图像我们必须设置选定的照片),然后他/她可以根据它们裁剪这些图像.完成裁剪后,他/她将在选定的相框中打开一个新视图,并在其中设置这两个裁剪后的图像那两个透明的整体.我已经种完了,直到播种结束.

I am making an application in which user will be allowed to select a photo frame firstly and after that he/she can have to select 2 photos from gallery for that photo frame (photo frame is an image which coontains two transparent holes in which we have to set the selected photos)and he/she can crop these image according to them.And after he/she is done with cropping a new view will get open with that selected photo frame and those two cropped images will be set in those two transparent whole. I have finished till the cropping is done.

如何在透明部分设置这两个图像,以使其在所有设备中正确显示,并且透明部分根据用户选择的相框而不断变化.

How to set those two images in the transparent portion so that it will show properly in all the devices and the transparent portion keeps changing according to the photo frames the user will select.

推荐答案

在视图上添加新图像. 添加手势以移动和调整新图像的大小(缩放),为新图像设置完美的位置(即在帧中心),然后将图像视图发送到主图像视图的背面. 之后,渲染两个视图,并使用UIGraphicsContext制作新图像.

Add new image on view. Add gesture to move and resize (zoom) new image, set perfect position for new image (i.e at centre of frame), Then send image view to back side of you main image view. After that render both view, and make new image with UIGraphicsContext.

我为您提供了渲染代码.

I have render code for you.

    UIGraphicsBeginImageContextWithOptions(self.viewCombineImages.bounds.size, false, 0.0)
    self.viewCombineImages.layer.render(in: UIGraphicsGetCurrentContext()!)
    let image = UIGraphicsGetImageFromCurrentImageContext()!
    UIGraphicsEndImageContext()

这篇关于iPhone:在Image的透明部分设置imageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆