Last active
August 29, 2015 14:28
-
-
Save fcaldarelli/f1178aa79ce6648ecc60 to your computer and use it in GitHub Desktop.
iOS Category methods to change constraints to UIView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface UIView(ChangeConstraint) | |
- (void)constraintChangeHeight:(CGFloat)fH; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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