lundi 29 juin 2015

Perform code when frame is changed


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?


Aucun commentaire:

Enregistrer un commentaire