summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Marinho <me@ruimarinho.net>2016-11-30 20:09:57 +0000
committerJason Smith <jason.smith@xamarin.com>2016-11-30 12:14:34 -0800
commit121ddafde56c66f0b720e2cb27c2f3aed13027f2 (patch)
treefea772757393a30ae3038bfca843e3b964d0a80e
parent44e0344c9749fb6a5df98c7b31e24bc30f8701ba (diff)
downloadxamarin-forms-121ddafde56c66f0b720e2cb27c2f3aed13027f2.tar.gz
xamarin-forms-121ddafde56c66f0b720e2cb27c2f3aed13027f2.tar.bz2
xamarin-forms-121ddafde56c66f0b720e2cb27c2f3aed13027f2.zip
[iOS] Avoid using DrawRect on base VisualElementRenderer (#570)
* [Controls] Add retro for Bugzilla 48158 * [iOS] Avoid using DrawRect as this will make some properties not being applied to the layer * [iOS] Make sure BoxRenderer calls base LayoutSubviews * [iOS] Better fix for adding the Blur effect and avoid override draw’s * [Controls] Remove extra nunit category
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla48158.cs29
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs11
4 files changed, 37 insertions, 6 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla48158.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla48158.cs
new file mode 100644
index 00000000..07f1c8c9
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla48158.cs
@@ -0,0 +1,29 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 48158, "Hidden controls become transparent, needs manual verification", PlatformAffected.iOS)]
+ public class Bugzilla48158 : TestContentPage // or TestMasterDetailPage, etc ...
+ {
+ protected override void Init()
+ {
+ var grdInner = new Grid { BackgroundColor = Color.Red, IsVisible = false, Padding = new Thickness(10) };
+ var btn = new Button { Text = "Click and verify background is red" };
+ btn.Clicked += (s, e) =>
+ {
+ grdInner.IsVisible = !grdInner.IsVisible;
+ };
+ var grd = new Grid();
+ grd.Children.Add(grdInner);
+ grd.Children.Add(btn);
+ Content = grd;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 9abd6ead..92fb8725 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -442,6 +442,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue55555.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41029.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39908.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla48158.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs
index 466773b5..f2b92530 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs
@@ -26,6 +26,8 @@ namespace Xamarin.Forms.Platform.iOS
{
if (_previousSize != Bounds.Size)
SetNeedsDisplay();
+
+ base.LayoutSubviews();
}
protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
diff --git a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
index b4a60f63..bb971858 100644
--- a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
@@ -170,17 +170,16 @@ namespace Xamarin.Forms.Platform.iOS
return new SizeF(0, 0);
}
- public override void Draw(RectangleF rect)
+ public override void LayoutSubviews()
{
- base.Draw(rect);
- if (_blur != null)
+ base.LayoutSubviews();
+ if (_blur != null && Superview != null)
{
- _blur.Frame = rect;
+ _blur.Frame = Bounds;
if (_blur.Superview == null)
Superview.Add(_blur);
}
}
-
protected override void Dispose(bool disposing)
{
if ((_flags & VisualElementRendererFlags.Disposed) != 0)
@@ -289,7 +288,7 @@ namespace Xamarin.Forms.Platform.iOS
}
_blur = new UIVisualEffectView(blurEffect);
- SetNeedsDisplay();
+ LayoutSubviews();
}
protected virtual void UpdateNativeWidget()