J'utilise ce code, ça marche, vraiment la taille de l'image 160x148 mais le bouton image est très grand sur tout l'écran!gif animé sur uibutton
UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"button1.png"],
[UIImage imageNamed:@"button2.png"],
[UIImage imageNamed:@"button3.png"],
[UIImage imageNamed:@"button4.png"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[yourButton addSubview: animatedImageView];
Comment résoudre ce problème?
Eh bien, c'est important parce que vous avez appelé initWithFrame: et passé dans les limites de votre vue. Changez-le en rect rectangle de taille différente. – Luke
Comment faire cela? – user1996717
Changez self.view.bounds en CGRectMake (0, 0, 160, 148) au moins, puis repositionnez-le où vous en avez besoin. – Luke