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?
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];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.