private void CreateLayout()
{
// Setup the visual frame for the MapView
_myMapView = new MapView()
{
Frame = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height- yPageOffset)
};
// Create a button to take the screenshot
var screenshotButton = new UIBarButtonItem() { Title = "Screenshot", Style = UIBarButtonItemStyle.Plain };
screenshotButton.Clicked += OnScreenshotButtonClicked;
// Initialize a button to close imageview
_closeImageViewButton = new UIBarButtonItem() { Title = "Close Preview", Style = UIBarButtonItemStyle.Plain };
_closeImageViewButton.Clicked += OnCloseImageViewClicked;
_closeImageViewButton.Enabled = false;
// Add the buttons to the toolbar
SetToolbarItems(new UIBarButtonItem[] {screenshotButton,
new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null),
_closeImageViewButton}, false);
// Show the toolbar
NavigationController.ToolbarHidden = false;
// Add the new View as an overlayview
_overlayView = new UIView()
{
Frame = new CoreGraphics.CGRect(10, 80, _myMapView.Frame.Width-20, _myMapView.Frame.Height-75)
};
// Create a new image view to hold the screenshot image
_overlayImageView = new UIImageView()
{
Frame = new CoreGraphics.CGRect(0, 0, _overlayView.Frame.Width, _overlayView.Frame.Height)
};
_overlayImageView.Layer.BorderColor = UIColor.White.CGColor;
_overlayImageView.Layer.BorderWidth = 2;
// Add the image view to the overlay view
_overlayView.AddSubview(_overlayImageView);
// Hide the image view
_overlayView.Hidden = true;
// Add MapView and overlay view to the page
View.AddSubviews(_myMapView, _overlayView);
}
}