我有一个图像编辑iOS应用程序。
我有T恤(父母图像)图像作为背景图像,我可以将其他图像(子图像)添加到T恤图像中。
当我缩放,移动,旋转子图像时,如果图像的一部分超出父图像的边界,那么该部分应该低于其alpha值。
同样,我已经在屏幕截图中显示。
我写了以下代码。
UIImageView* randomView = [[UIImageView alloc] initWithFrame:self.imageView.bounds];
randomView.userInteractionEnabled = YES;
randomView.alpha = 0.8;
randomView.image = image; // 'image' coming from gallery or camera
UIImageView *maskView = [[UIImageView alloc] initWithImage:self.imageView.image];
[maskView setFrame:self.imageView.bounds];
self.imageView.layer.mask = maskView.layer;
[self.imageView setNeedsDisplay];
答案 0 :(得分:0)
在T恤视图后面再添加一个imageView(带有alpha的主图像副本)。