FabrizioCaldarelli
8/25/2015 - 7:39 AM

iOS Category methods to change constraints to UIView

iOS Category methods to change constraints to UIView

#import "UIView+ChangeConstraint.h"

@implementation UIView(ChangeConstraint)

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)constraintChangeHeight:(CGFloat)fH
{
    for (NSLayoutConstraint *lc in self.constraints) {
        if((lc.firstAttribute == NSLayoutAttributeHeight)&&(lc.firstItem == self)&&(lc.secondItem == NSLayoutAttributeNotAnAttribute))
        {
            lc.constant = fH;
        }
    }
}

@end
#import <UIKit/UIKit.h>

@interface UIView(ChangeConstraint)

- (void)constraintChangeHeight:(CGFloat)fH;

@end