2013-11-15 53 views
0

enter image description here enter image description here在我的應用程序圖像是在字幕效果(HTML)。所以我通過使用NSTimer來設置圖像的x點,但它實現成功,但圖像顯示出一些模糊。我如何消除這種模糊效果?字幕動畫UIimageView模糊

int x=0; 
ImgArray=[[NSMutableArray alloc] initWithObjects:[UIImage imageNamed:@"keyframe1.png"],[UIImage imageNamed:@"keyframe2.png"],[UIImage imageNamed:@"keyframe3.png"],[UIImage imageNamed:@"keyframe4.png"], [UIImage imageNamed:@"keyframe5.png"],nil]; 

imgView=[[UIImageView alloc]initWithFrame:CGRectMake(x, 0, 1024, 768)];` 
imgView.image=[ImgArray objectAtIndex:0]; 
[self.view addSubview:imgView]; 
[NSTimer scheduledTimerWithTimeInterval:.08 target:self selector:@selector(showMarquee) userInfo:nil repeats:YES]; 
在showMarquee方法

改變X

+0

使用UIView動畫而不是NStimer。 –

+0

檢查圖像的分辨率。 – Smita

+0

不確定其他人,但我不知道「跑馬燈效果」是什麼。你可以發佈一些代碼嗎? – derpoliuk

回答

0

用於選取框效果下面的代碼的值。

聲明CAShapeLayer對象

CAShapeLayer *_marque; 

使用下面的方法:

-(void)setMarquee { 

    if (!_marque) { 
     _marque = [CAShapeLayer layer] ; 
     _marque.fillColor = [[UIColor clearColor] CGColor]; 
     _marque.strokeColor = [[UIColor grayColor] CGColor]; 
     _marque.lineWidth = 1.0f; 
     _marque.lineJoin = kCALineJoinRound; 
     _marque.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:10],[NSNumber numberWithInt:5], nil]; 
     _marque.bounds = CGRectMake(self.imgView.frame.origin.x, self.imgView.frame.origin.y, 0, 0); 
     _marque.position = CGPointMake(self.imgView.frame.origin.x + self.imgView.frame.origin.x, self.imgView.frame.origin.y + self.imgView.frame.origin.y); 
    } 
    [self.view.layer addSublayer:_marque]; 
} 

-(void)showOverlayWithFrame:(CGRect)frame { 

     if (![_marque actionForKey:@"linePhase"]) { 
      CABasicAnimation *dashAnimation; 
      dashAnimation = [CABasicAnimation animationWithKeyPath:@"lineDashPhase"]; 
      [dashAnimation setFromValue:[NSNumber numberWithFloat:0.0f]]; 
      [dashAnimation setToValue:[NSNumber numberWithFloat:15.0f]]; 
      [dashAnimation setDuration:0.5f]; 
      [dashAnimation setRepeatCount:HUGE_VALF]; 
      [_marque addAnimation:dashAnimation forKey:@"linePhase"]; 
     } 

     _marque.bounds = CGRectMake(frame.origin.x, frame.origin.y, 0, 0); 
     _marque.position = CGPointMake(frame.origin.x + self.imgView.frame.origin.x, frame.origin.y + self.imgView.frame.origin.y); 

     CGMutablePathRef path = CGPathCreateMutable(); 
     CGPathAddRect(path, NULL, frame); 
     [_marque setPath:path]; 
     CGPathRelease(path); 

     _marque.hidden = NO; 


} 

現在所說的方法

[self setMarquee]; 
[self showOverlayWithFrame:self.imgView.frame]; 

就指這個項目

https://www.cocoacontrols.com/controls/kaslideshow

+0

謝謝..manujmv。它的顯示線在跑馬燈動畫,但我需要從左到右的選取框動畫 –

+0

可以添加你試過的屏幕截圖 – manujmv

+0

請檢查屏幕.. –