How to listen a frame property of a view on iOS
<p>I have a view and I added a observer like this:</p><pre><br /><code>_aView = [UIView new];<br />[_aView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];<br />_aView.frame = CGRectMake(100, 100, 100, 100);<br /></code><br /></pre><p>In the observer method I get the new value : <code>- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqualToString:@"frame"]) { NSLog(@"%@", change[@"new"]); } }</code> The log is <code>NSRect: {{100, 100}, {100, 100}}</code>. The question is that I got the value type is <code>NSRect</code>, how to convert it to <code>CGRect</code>?</p><p>In the UIKit library have no type named <code>NSRect</code></p><br /><h2>Click here view more answers <a href="%20http://stackoverflow.com/questions/34524964/how-to-listen-a-frame-property-of-a-view-on-ios">http://ift.tt/1OYN2ZB</a></h2>
Nhận xét
Đăng nhận xét