Created
October 27, 2015 15:57
-
-
Save KiranPanesar/f0dfa5a7c50c1c66d603 to your computer and use it in GitHub Desktop.
A UIImageView subclass which allows for external memers to set the intrinsicContentSize
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
// | |
// NTVImageView.h | |
// | |
// Created by kiran on 27/10/2015. | |
// | |
#import <UIKit/UIKit.h> | |
@interface NTVImageView : UIImageView | |
/** | |
* A property to constrain the contentSize of the receiver. | |
* | |
* This will automatically call `invalidateIntrinsicContentSize` on the receiver | |
* to trigger a layout pass. | |
*/ | |
@property (assign, nonatomic, readwrite) CGSize constrainedSize; | |
@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
// | |
// NTVImageView.m | |
// | |
// Created by kiran on 27/10/2015. | |
// | |
#import "NTVImageView.h" | |
@implementation NTVImageView | |
- (CGSize)intrinsicContentSize { | |
return self.constrainedSize; | |
} | |
- (void)setConstrainedSize:(CGSize)constrainedSize { | |
_constrainedSize = constrainedSize; | |
[self invalidateIntrinsicContentSize]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment