Reputation: 12565
Resizing a UIView's height can be done by modifying it's frame.size.height
property OR by modifying it's NSLayoutHeight
constraint. However, by default, reducing a UIView's height will cut off the UIView from the bottom up, I need to reduce a UIView's height from the top down. Is this possible?
Upvotes: 1
Views: 635
Reputation: 1
Create container UIView with clipsToBounds == YES, and move your view inside the container view. Just like clipping mask in drawing software.
Upvotes: 0
Reputation: 16467
You will need to adjust the origin of the frame as well.
Eg:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 20.0, 40.0)];
to change the height to 30.0
from the 'top down' do:
view.frame = CGRectMake(0.0, 10.0, 20.0, 30.0);
Upvotes: 1
Reputation: 6480
Adjust the origin.y
of the view as you change the height.
CGFloat const delta = 100;
[aView setFrame:CGRectMake(CGRectGetMinX([aView frame]), CGRectGetMinY([aView frame]) + delta, CGRectGetWidth([aView bounds]), CGRectGetHeight([aView bounds]) - delta)];
Upvotes: 1