Reputation: 101
I have a user resizable view created programmatically using the files downloaded from git Resize I have added a label over this view and I need the label to be at the center of the resizable view always . How can i adjust size and location of the label according to the resizable view?
Upvotes: 0
Views: 148
Reputation: 9942
This is a job for autolayout. Should be easily solved using
-(NSArray *)centerInView:(UIView*)superview;
or
-(NSLayoutConstraint *)centerInContainerOnAxis:(NSLayoutAttribute)axis;
in the excellent autolayout category found here:
https://github.com/jrturton/UIView-Autolayout
Examples:
[self.imageLabel centerInView:self.imageView];
[self.imageLabel centerInContainerOnAxis:NSLayoutAttributeCenterY];
Upvotes: 1