[iOS] Extract native control creation into separate method like in androids ButtonRen...
authorIvan <lamest@users.noreply.github.com>
Tue, 12 Dec 2017 12:45:59 +0000 (19:45 +0700)
committerRui Marinho <me@ruimarinho.net>
Tue, 12 Dec 2017 12:45:59 +0000 (12:45 +0000)
Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs
Xamarin.Forms.Platform.iOS/ViewRenderer.cs

index f417dd7..838bb36 100644 (file)
@@ -56,7 +56,7 @@ namespace Xamarin.Forms.Platform.iOS
                        {
                                if (Control == null)
                                {
-                                       SetNativeControl(new UIButton(UIButtonType.System));
+                                       SetNativeControl(CreateNativeControl());
 
                                        Debug.Assert(Control != null, "Control != null");
 
@@ -78,6 +78,11 @@ namespace Xamarin.Forms.Platform.iOS
                        }
                }
 
+               protected override UIButton CreateNativeControl()
+               {
+                       return new UIButton(UIButtonType.System);
+               }
+
                protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
                {
                        base.OnElementPropertyChanged(sender, e);
index 5ea6a94..2c0ae92 100644 (file)
@@ -31,6 +31,11 @@ namespace Xamarin.Forms.Platform.MacOS
 #endif
                NativeColor _defaultColor;
 
+               protected virtual TNativeView CreateNativeControl()
+               {
+                       return default(TNativeView);
+               }
+
                public TNativeView Control { get; private set; }
 #if __MOBILE__
                public override void LayoutSubviews()