public void Ctor_MKMapView() { using (MKMapView mv = new MKMapView()) using (MKUserTrackingBarButtonItem ut = new MKUserTrackingBarButtonItem(mv)) { Assert.AreSame(mv, ut.MapView, "MapView"); } }
public void Ctor_Defaults() { using (var a = new NSObject()) using (MKUserTrackingBarButtonItem ut = new MKUserTrackingBarButtonItem()) { Assert.Null(ut.MapView, "MapView"); } }
public void Ctor_MKMapView() { if (!TestRuntime.CheckSDKVersion(7, 0)) { Assert.Ignore("This test crashes with the iOS 6 SDK and an iOS 7 device [iOS bug] (so just force at least an iOS 7 SDK)"); } using (MKMapView mv = new MKMapView()) using (MKUserTrackingBarButtonItem ut = new MKUserTrackingBarButtonItem(mv)) { Assert.AreSame(mv, ut.MapView, "MapView"); } }
private void AddToolbar(MKMapView nativeMap) { // Map Tracking button MKUserTrackingBarButtonItem trackingButton = new MKUserTrackingBarButtonItem(nativeMap); trackingButton.CustomView.Frame = new CGRect(x: trackingButton.CustomView.Frame.X, y: trackingButton.CustomView.Frame.Y, width: 44, height: 44); trackingButton.CustomView.Transform = CGAffineTransform.MakeRotation((nfloat)(-270.0 / 180 * Math.PI)); // Add Feature Button UIButton addFeatureButton = new UIButton(UIButtonType.ContactAdd) { Frame = new CGRect(x: trackingButton.CustomView.Frame.X, y: trackingButton.CustomView.Frame.Y, width: 44, height: 44), Transform = CGAffineTransform.MakeRotation((nfloat)(-270.0 / 180 * Math.PI)) }; addFeatureButton.TouchUpInside += (sender, e) => { NavigationService navigationService = (NavigationService)DependencyService.Get <INavigationService <Feature> >(); _ = navigationService.PushAddFeaturePage(); }; UIBarButtonItem addFeatureButtonItem = new UIBarButtonItem(addFeatureButton); // Flexible Seperator UIBarButtonItem flex = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, target: this, action: null); // Toolbar Items Aray UIBarButtonItem[] ButtonsArray = new UIBarButtonItem[] { flex, trackingButton, flex, addFeatureButtonItem, flex }; // Toolbar and frame CGRect toolBarFrame = new CGRect(location: new CGPoint(x: 0, y: 0), size: new CGSize(width: 88, height: 44)); UIToolbar toolbar = new UIToolbar(frame: toolBarFrame) { BarTintColor = UIColor.SystemBackgroundColor, Translucent = true }; toolbar.SetItems(ButtonsArray, true); // Set toolbar position CGPoint origin = new CGPoint(x: UIScreen.MainScreen.Bounds.Width - 75, y: 75); // Create base view for button UIView baseView = new UIView(frame: new CGRect(location: origin, size: new CGSize(width: 88, height: 44))) { BackgroundColor = UIColor.Clear }; // Shadow effects baseView.Layer.ShadowColor = UIColor.Black.CGColor; baseView.Layer.ShadowOpacity = 0.3f; baseView.Layer.ShadowOffset = new CGSize(width: 0, height: 0); baseView.Layer.ShadowRadius = 4.0f; // Rounded border view for button UIView borderview = new UIView { Frame = baseView.Bounds }; borderview.Layer.CornerRadius = 10; borderview.Layer.MasksToBounds = true; baseView.Transform = CGAffineTransform.MakeRotation((nfloat)(270.0 / 180 * Math.PI)); // Stack subviews borderview.AddSubview(toolbar); baseView.AddSubview(borderview); nativeMap.AddSubview(baseView); }