我想要在蒙版中放置一個蒙版。出現任何經過蒙版後面傳遞的圖像視圖。所以這裏是我的代碼到目前爲止,但這個代碼的問題是它動畫蒙版與圖像視圖。用蒙版動畫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