Reputation: 9830
I have a custom class that's a subclass of UIView
. In the storyboard
I set a UIView's
class to the custom class. The view
in the storyboard
has a height constraint
so that I can change the height programmatically. (I know it's not the only way, but I think it's the easiest way.)
I want to perform some code in the custom class every time the view's
height changes.
I tried the following:
- (void)setFrame:(CGRect)frame {
[super setFrame:frame};
NSLog(@"Frame did change");
}
But this method only runs on startup, not when it's (self
) height was changed. How can I perform code anytime it's frame is changed?
Upvotes: 1
Views: 31
Reputation: 21726
Just override layoutSubviews
method in your custom view class
- (void)layoutSubviews
{
[super layoutSubviews];
NSLog(@"Frame did change");
}
Upvotes: 2