I have code that says when a button is clicked, the one below moves down. I want to know if it’s possible to make it so when the button is clicked again, the button below moves back to its original position.
.h
@interface ViewController : UIViewController {
IBOutlet UIButton *button;
}
-(IBAction)buttonClicked:(id)sender;
-(IBAction)buttonClicked1:(id)sender;
@end
.m
- (void)buttonClicked:(id)sender {
CGRect frame = button.frame;
frame.origin.x = 65; // new x coordinate
frame.origin.y = 130; // new y coordinate
button.frame = frame;
}
You can use a
BOOLto keep track of state and store the startRect for moving the button back.h
.m