-1

I have a button called loginButton and I want to change its frame position and have tried several ways. One method is this:

var newFrame = loginButton.frame;
newFrame.origin.y -= 100; 
loginButton.frame = newFrame;

The other method is this:

loginButton.frame.origin = CGPoint(x: 16, y: 204)

None of these seem to do the job. Does anyone know why?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Arnav GUPTA
  • 295
  • 1
  • 2
  • 17

1 Answers1

0

It's because you've already positioned this button using autolayout constraints. You cannot fight against autolayout with frame settings. If you want to reposition the button, you must change the constraints.

matt
  • 515,959
  • 87
  • 875
  • 1,141