Wenting Liu
Wenting Liu
- (void)centerAlignHorizontalForView:(UIView *)view offset:(CGFloat)offset { [self setFrame:CGRectRound(CGRectMake((CGRectGetWidth([view frame]) / 2.0f) - (CGRectGetWidth([self frame]) / 2.0f) + offset, CGRectGetMinY([self frame]), CGRectGetWidth([self frame]), CGRectGetHeight([self frame])))]; } --- Should also add [view frame].origin.x.
- (void)centerAlignVerticalForView:(UIView *)view offset:(CGFloat)offset { [self setFrame:CGRectRound(CGRectMake(CGRectGetMinX([self frame]), (CGRectGetHeight([view frame]) / 2.0f) - (CGRectGetHeight([self frame]) / 2.0f) + offset, CGRectGetWidth([self frame]), CGRectGetHeight([self frame])))]; } ## Should also add [view frame].origin.y.