I have a view and I added a observer like this:
_aView = [UIView new];
[_aView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];
_aView.frame = CGRectMake(100, 100, 100, 100);
In the observer method I get the new value :
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
if ([keyPath isEqualToString:@"frame"]) {
NSLog(@"%@", change[@"new"]);
}
}
The log is NSRect: {{100, 100}, {100, 100}}
.
The question is that I got the value type is NSRect
, how to convert it to CGRect
?
In the UIKit library have no type named NSRect