Mikhail
Mikhail

Reputation: 869

Strange UIView.animateWithDuration compilation error if have some code in animations block

I have code

UIView.animateWithDuration(0.5, delay: 0.4, options: .Repeat, animations: { // self.circle.center += 10 }, completion: nil) }

which compiles. But if I uncomment line self.circle.center += 10 I would have ViewController.swift:28:23: Could not find member 'Repeat'.

self.circle is @IBOutlet var circle: Circle! connected to certain object on Main.storyboard. Circle is class extending UIView with custom drawRect.

What 's wrong with all of this stuff?

Upvotes: 1

Views: 149

Answers (1)

Stephen Fox
Stephen Fox

Reputation: 14470

To add +10 to the center point you would need to do something like this:

self.circle.center.x += 10
self.circle.center.y += 10

The center property is a CGPoint containing an x and y value. So adding +10 to the just the center alone doesn't really make sense.

struct CGPoint {
    var x: CGFloat
    var y: CGFloat
}

Upvotes: 1

Related Questions