Jason Tu
Jason Tu

Reputation: 59

PureLayout Center with Offset

I've been trying to center the following UIView to be 70 pixels above the absolute center of the phone. I would like to use PureLayout so that the constraint will change when I use split screen on an iPad or rotate the screen. Here is my current code:

self.checkBall.frame.origin.x = self.view.bounds.width/2 - self.checkBall.frame.width/2 + 70
self.checkBall.frame.origin.y = self.view.bounds.height/2 - self.checkBall.frame.height/2 - 70

Upvotes: 1

Views: 652

Answers (1)

Jake T.
Jake T.

Reputation: 4378

You're using PureLayout?

self.checkBall.autoAlignAxis(.vertical, toSameAxisOf: self.view)
self.checkBall.autoAlignAxis(.horizontal, toSameAxisOf: self.view, withOffset: -70.0)

Upvotes: 1

Related Questions