我想要在蒙版中放置一个蒙版。出现任何经过蒙版后面传递的图像视图。所以这里是我的代码到目前为止,但这个代码的问题是它动画蒙版与图像视图。用蒙版动画UIImageView,但蒙版是静态的
UIView *maskView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.worldImageView.frame.size.height, self.worldImageView.frame.size.height)];
// ...position maskView...
maskView.layer.position = CGPointMake(CGRectGetMidX([self.view bounds]), CGRectGetMidY([self.view bounds]));
maskView.layer.backgroundColor = [UIColor blackColor].CGColor;
maskView.layer.cornerRadius = 90;
self.worldImage = [[UIImageView alloc] init];
self.worldImage.frame = self.worldImageView.frame;
self.worldImage.image = [UIImage imageNamed:@"continents.png"];
[maskView addSubview:self.worldImage];
[self.view addSubview:maskView];
CABasicAnimation* worldAnimation = [[CABasicAnimation alloc] init];
[worldAnimation setFromValue:[NSValue valueWithCGPoint:CGPointMake(self.view.frame.size.width + 50, CGRectGetMidY([maskView bounds]))]];
[worldAnimation setToValue:[NSValue valueWithCGPoint:CGPointMake(-50, CGRectGetMidY([maskView bounds]))]];
worldAnimation.keyPath = @"position";
worldAnimation.duration = 6.0f;
worldAnimation.repeatCount = HUGE_VALF;
[[self.worldImage layer] addAnimation:worldAnimation forKey:nil];
我不知道我是否解释得很好。请告诉我,如果你需要更多的信息。先谢谢你!
你说的是面具随图像移动,但你不想要它? – ravron 2014-10-11 01:38:36
是的图像视图在动画时仍然被遮罩。 – PoKoBros 2014-10-11 01:44:08
好的,但你想要做什么?你是说你想让面具代表的“窗口”静止不动,而图像在它后面移动? – ravron 2014-10-11 01:46:05