J'ai une image sunrays. Je tiens à le mettre sur le fond et la faire tourner dans un mouvement continuosly lent ..Rotation Animation sur UIImageView
L'image est ce ..
J'ai essayé en rotation avec CABasicAnimation, mais il tourne toute la trame .. je veux juste les sunrays pour tourner à l'arrière-plan pas toute la trame ..
Y at-il un moyen de le faire ???
Mise à jour:
Voici ce que fais ... s'il vous plaît signaler mes erreurs ... :(
je n'ai pas obtenu wat u've expliqué .. :(
voici ce que fais ...
- (void)viewDidLoad {
sunraysContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
sunraysContainer.clipsToBounds = YES;
[self.view addSubview:sunraysContainer];
sunrays = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[sunrays setImage:[UIImage imageNamed:@"sunlight-background copy2.jpg"]];
[sunraysContainer addSubview:sunrays];
backgroundBuilding = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[backgroundBuilding setImage:[UIImage imageNamed:@"hira-background_fade.png"]];
[sunraysContainer addSubview:backgroundBuilding];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:5];
CABasicAnimation *rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2.0 * 4.0];
rotationAnimation.duration = 1;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 10;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[sunrays.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
[UIView commitAnimations];
}
Mise à jour ...
Je l'ai fait ce que tu dit ... nachos merci pour votre réponse, mais m obtenir un blankscreen .. :(
j'ai dis ... codé
sunrays = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sunlight-background copy2.jpg"]];
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,sunrays.frame.size.height,sunrays.frame.size.height)];
[container setClipsToBounds:YES];
[container addSubview:sunrays];
[sunrays setCenter:CGPointMake(container.bounds.size.width/2, container.bounds.size.height/2)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:5];
CABasicAnimation *rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2.0 * 4.0];
rotationAnimation.duration = 1;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 10;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[sunrays.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
[UIView commitAnimations];
ce qui est mal wid le code? ?
m n'a pas obtenu ce que u .. :(expliqué – Hisenberg
j'ai édité mon code. ..n maintenant il apparaît comme écran blanc vide ... – Hisenberg
J'ai mis à jour ma réponse, s'il vous plaît jeter un oeil. BTW, si vous avez besoin d'un conteneur pour être plus grand, alors vous aurez besoin d'une image plus grande car actuellement est la plus grande posible, sinon vous verrez l'effet de rotation du cadre. Les maths sont très simples. Vous ne devriez pas avoir de problèmes avec cela;) – nacho4d