Hi
I am trying to animate a button to change it's shape and position (CGRect) using cocoa animation. I make the button using one method, and then call the method to animate the button. This method is called (an NSLog runs to tell me this) however the animation does not take place.
I've reviewed my code copious times, and referred to my reference texts, but just can't figure out why it's not working. If anybody can figure it out, I'd be just so grateful.
In my implementation file, I have:
and in my header file, I have:
Any ideas?
Thanks,
Sam
I am trying to animate a button to change it's shape and position (CGRect) using cocoa animation. I make the button using one method, and then call the method to animate the button. This method is called (an NSLog runs to tell me this) however the animation does not take place.
I've reviewed my code copious times, and referred to my reference texts, but just can't figure out why it's not working. If anybody can figure it out, I'd be just so grateful.
In my implementation file, I have:
Code:
@implementation ViewController
UIButton *button;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self makeButton];
[self moveButton:button];
}
- (void)makeButton {
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(methodToCallWhenButtonPressed)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)moveButton:(UIButton *)buttonToUse {
NSLog(@"Called");
[UIView animateWithDuration:0.5 delay:0.0 options:nil animations:^{
buttonToUse.frame = CGRectMake(10, 10, 300, 440);
} completion:^(BOOL finished){
}];
}
Code:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
- (void) makeButton;
- (void) moveButton:(UIButton *)buttonToUse;
@end
Any ideas?
Thanks,
Sam