這是一個非常非常微妙的效果,但我注意到我的UIImageView圖像在被拖動後變得稍微模糊。UIImageView平移後失去質量?
我只是使用UIPanGestureRecognizer在屏幕上移動它,並在移動時影響Alpha(使UI效果拖動時變得更亮)。
有沒有人有線索,爲什麼它會失去一些圖像質量,並得到一點模糊?
-(void)handlePan:(UIPanGestureRecognizer *)recognizer{
self.alpha = 0.7;
CGPoint translation = [recognizer translationInView:self.superview];
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:self.superview];
//make the sprite slide on release
if (recognizer.state == UIGestureRecognizerStateEnded){
self.alpha = 1.0;
CGPoint velocity = [recognizer velocityInView:self.superview];
CGFloat magnitude = sqrtf((velocity.x * velocity.x) + (velocity.y * velocity.y));
CGFloat slideMult = magnitude/200;
float slideFactor = 0.01 *slideMult; //increase for more slide
CGPoint finalPoint = CGPointMake(recognizer.view.center.x + (velocity.x *slideFactor), recognizer.view.center.y + (velocity.y * slideFactor));
finalPoint.x = MIN(MAX(finalPoint.x, 0), self.superview.bounds.size.width);
finalPoint.y = MIN(MAX(finalPoint.y, 0), self.superview.bounds.size.height);
[UIView animateWithDuration:slideFactor*2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{recognizer.view.center = finalPoint;}
completion:nil];
*編輯:我相信這與狀態結束時的滑動效果有關。
請在移動圖像時發佈您正在使用的代碼。 – PengOne 2012-01-13 00:00:20