0

I am stuck trying to animate a UIView that I created on the Main.StoryBoard.

I created the outlet for it in my ViewController.h file.

@property (strong, nonatomic) IBOutlet UIImageView *Player;

The animation I attempted was:

 - (void) PlayerMoves {
    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveLinear animations: self.Player.center = CGPointMake(self.Player.center.x, self.Player.center.y -50) completion:nil]; 
}

Anything I do, it tells me that I have an error.

Sending 'CGPoint' (aka 'struct CGPoint') to parameter of incompatible type 'void (^ _Nonnull)(void)'

Pang
  • 9,564
  • 146
  • 81
  • 122
  • If I left out something that I needed to have included please let me know. Thanks in Advanced guys! – Patrick Sway Feb 28 '16 at 04:27
  • Probably want to have a look at these links: [1. UIView animation](http://stackoverflow.com/questions/4156840/uiview-animation) . [2. iPhone UIView Animation Best Practice](http://stackoverflow.com/questions/630265/iphone-uiview-animation-best-practice) . [3. iOS Animation Tutorial: Getting Started](http://www.raywenderlich.com/113674/ios-animation-tutorial-getting-started) – Abhijeet Feb 28 '16 at 05:07
  • Thanks for the links and thanks to all who helped. – Patrick Sway Feb 28 '16 at 18:59

1 Answers1

0

You should pass blocks into animateWithDuration. An example:

[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
    // your animation here
    self.Player.center = CGPointMake(self.Player.center.x, self.Player.center.y -50)
} completion:nil];

Parameter animations in this method is type of (void (^)(void)). You need to read a bit more about blocks in Objective-C and how to use them.

Nimble
  • 1,009
  • 1
  • 11
  • 11