Animación de marquesina UIimageView desenfoque
Frecuentes
Visto 534 veces
0
En mi aplicación, las imágenes están en efecto Marquee (HTML). así que configuré el punto x de la imagen usando
NSTimer
pero se implementó con éxito, pero la imagen muestra algo de desenfoque. ¿Cómo elimino este efecto de desenfoque?
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];
en el método showMarquee cambia el valor de x
1 Respuestas
0
Utilice el siguiente código para el efecto de marquesina.
declarar CAShapeLayer objeto
CAShapeLayer *_marque;
Utilice los siguientes métodos:
-(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;
}
Ahora llame a los métodos
[self setMarquee];
[self showOverlayWithFrame:self.imgView.frame];
Simplemente consulte este proyecto
respondido 15 nov., 13:09
Gracias ..manujmv. su línea de visualización en la animación de marquesina pero necesito imágenes en la animación de marquesina de izquierda a derecha - Rinju jainista
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas ios objective-c uiimageview or haz tu propia pregunta.
Use UIView Animation en lugar de NStimer. - Anand Suthar
Compruebe la resolución de la imagen. - iSmita
No estoy seguro de los demás, pero no sé qué es el "efecto Marquee". ¿Puedes publicar algún código? - derpoliuk