Skip to content

Instantly share code, notes, and snippets.

@fcaldarelli
Last active August 29, 2015 14:28
Show Gist options
  • Save fcaldarelli/f1178aa79ce6648ecc60 to your computer and use it in GitHub Desktop.
Save fcaldarelli/f1178aa79ce6648ecc60 to your computer and use it in GitHub Desktop.
iOS Category methods to change constraints to UIView
#import <UIKit/UIKit.h>
@interface UIView(ChangeConstraint)
- (void)constraintChangeHeight:(CGFloat)fH;
@end
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment