Reputation: 3517
The method on stackoverflow to position a button is not working. I'm using
self.todayButton.frame = CGRectMake(0, self.todayButton.frame.origin.y, self.todayButton.frame.size.width, self.todayButton.frame.size.height);
I think its an autolayout issue but i'm not sure how to fix.
Upvotes: 0
Views: 4205
Reputation: 9484
This is an issue with Autolayout
. But you can't disable autolayout
on a specific view in the nib. It has to be disabled on the whole nib.
Better solution is to use setTranslatesAutoresizingMaskIntoConstraints
on that button:
[self.todayButton setTranslatesAutoresizingMaskIntoConstraints:YES];
Upvotes: 5
Reputation: 667
It might be worth splitting this code up so you can see what the new frame looks like:
CGRect newFrame = self.todayButton.frame;
NSLog(@"Old: %@", NSStringFromCGRect(newFrame));
newFrame.origin.x = 0;
NSLog(@"New: %@", NSStringFromCGRect(newFrame));
self.todayButton.frame = newFrame;
Does the displayed frame look like what you expected?
Upvotes: 1