user1996717
user1996717

Reputation: 65

animated gif on uibutton

I use this code, that work, really size of image 160x148 but image button is view very big on all screen!

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];

How fix that?

Upvotes: 1

Views: 1508

Answers (2)

Krishnan8190
Krishnan8190

Reputation: 320

Try this code.It will help you for correct solution.

 UIImage *myimage=UIImage imageNamed:@"button1.png";
Button.imageview.image=myimage;

Upvotes: 0

Luke
Luke

Reputation: 11476

The images are big because you called initWithFrame: and passed in your view's bounds. Change it to a different-sized rect, such as:

CGRectMake(0, 0, 160, 148)

... and then reposition it as you see fit.

Upvotes: 2

Related Questions