Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[KeyValueObserving] Observe View's layer changes, bug #29339
  • Loading branch information
olegoid committed Apr 24, 2015
1 parent 363ad78 commit 5713e4a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions KeyValueObserving/AppDelegate.cs
Expand Up @@ -27,24 +27,26 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
Lines = 20,
BackgroundColor = UIColor.LightGray
};

topController.View.AddSubview (label);

window = new UIWindow (UIScreen.MainScreen.Bounds) {
RootViewController = topController
};

window.MakeKeyAndVisible ();

//
// Observe changes to the topController's View property, in this case, we want to
// Observe changes to the main View layer, in this case, we want to
// observe changes to the "bounds" property (this is the name of the Objective-C
// property).
//
// The changes observed are delivered to "this", which is expected to override
// the "ObserveValue" method.
//
topController.View.AddObserver (observer: this,
topController.View.Layer.AddObserver (observer: this,
keyPath: new NSString ("bounds"),
options: NSKeyValueObservingOptions.New,
options: NSKeyValueObservingOptions.New,
context: IntPtr.Zero);
return true;
}
Expand Down

0 comments on commit 5713e4a

Please sign in to comment.