Created
August 28, 2015 15:18
-
-
Save jyliang/ac44f2679cf647595bee to your computer and use it in GitHub Desktop.
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
@interface UIView (FrameObserver) | |
@end | |
@implementation UIView (FrameObserver) | |
- (void)observerFrame { | |
[self addObserver:self forKeyPath:@"frame" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"bounds" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"transform" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"position" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"zPosition" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"anchorPoint" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"anchorPointZ" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"frame" options:0 context:NULL]; | |
} | |
- (void)unObserverFrame { | |
[self removeObserver:self forKeyPath:@"frame"]; | |
[self.layer removeObserver:self forKeyPath:@"bounds"]; | |
[self.layer removeObserver:self forKeyPath:@"transform"]; | |
[self.layer removeObserver:self forKeyPath:@"position"]; | |
[self.layer removeObserver:self forKeyPath:@"zPosition"]; | |
[self.layer removeObserver:self forKeyPath:@"anchorPoint"]; | |
[self.layer removeObserver:self forKeyPath:@"anchorPointZ"]; | |
[self.layer removeObserver:self forKeyPath:@"frame"]; | |
} | |
- (void)observeValueForKeyPath:(NSString *)keyPath | |
ofObject:(id)object | |
change:(NSDictionary *)change | |
context:(void *)context { | |
NSLog(@"------------------------------------------------------------------------------"); | |
NSLog(@"%@", keyPath); | |
NSLog(@"Change list: %@", change); | |
NSLog(@"------------------------------------------------------------------------------"); | |
NSLog(@"%@",[NSThread callStackSymbols]); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment