summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS/Platform.cs
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-06-20 09:40:07 -0600
committerRui Marinho <me@ruimarinho.net>2017-06-20 16:40:07 +0100
commit99074753a0f20414be8eb423153fd6aaaafef87b (patch)
tree8aebc0c48dcf1a3de6c6e3eaddf37604032ef812 /Xamarin.Forms.Platform.iOS/Platform.cs
parentf7c943dc7798b3449d2bf8319aca8a9ab448ffec (diff)
downloadxamarin-forms-99074753a0f20414be8eb423153fd6aaaafef87b.tar.gz
xamarin-forms-99074753a0f20414be8eb423153fd6aaaafef87b.tar.bz2
xamarin-forms-99074753a0f20414be8eb423153fd6aaaafef87b.zip
Align Layout transparency behavior between Android, iOS, Windows (#935)
* Setting up repros * Tests for all combos of opacity, background color, and InputTransparent * Make InputTransparent work correctly for Layouts on Windows * Prevent low opacity from making Layouts implicitly input transparent * Real target values in TransparentOverlayTests * Allow layouts with transparent backgrounds to be clickable * Fix gesture bubbling behavior for layouts * Fix spacing * Remove dead code and usings * Fix spacing * Add missing using directive * Adjust transparent overlay test to work with iOS quirks * Fix spacing * Fix bugs caused by not filtering ACTION_CANCEL in MotionEventHelper * Attempting to fix the tests on iOS (where UI tests can't see the buttons) * Remove extra lines * Another attempt to get tests working on iOS * Another attempt to get iOS UI tests working for transparent overlays
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Platform.cs')
-rw-r--r--Xamarin.Forms.Platform.iOS/Platform.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Platform.cs b/Xamarin.Forms.Platform.iOS/Platform.cs
index b3542d69..5a442bab 100644
--- a/Xamarin.Forms.Platform.iOS/Platform.cs
+++ b/Xamarin.Forms.Platform.iOS/Platform.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using CoreGraphics;
using Foundation;
using UIKit;
using RectangleF = CoreGraphics.CGRect;
@@ -478,6 +479,30 @@ namespace Xamarin.Forms.Platform.iOS
internal class DefaultRenderer : VisualElementRenderer<VisualElement>
{
+ public override UIView HitTest(CGPoint point, UIEvent uievent)
+ {
+ // UIview hit testing ignores objects which have an alpha of less than 0.01
+ // (see https://developer.apple.com/reference/uikit/uiview/1622469-hittest)
+ // To prevent layouts with low opacity from being implicitly input transparent,
+ // we need to temporarily bump their alpha value during the actual hit testing,
+ // then restore it. If the opacity is high enough or user interaction is disabled,
+ // we don't have to worry about it.
+
+ nfloat old = Alpha;
+ if (UserInteractionEnabled && old <= 0.01)
+ {
+ Alpha = (nfloat)0.011;
+ }
+
+ var result = base.HitTest(point, uievent);
+
+ if (UserInteractionEnabled && old <= 0.01)
+ {
+ Alpha = old;
+ }
+
+ return result;
+ }
}
}
} \ No newline at end of file