xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.64k stars 1.88k forks source link

[Bug] DragGestureRecognizer on iOS sets the background color to the theme color when dragging an element #14878

Open takecx opened 2 years ago

takecx commented 2 years ago

Description

I am creating a mobile app using Xamarin.Forms. I need to implement drag-and-drop handling, and I have implemented drag-and-drop handling for the target element by referring to the following page.

Add drag and drop gesture recognizers

The problem occurred when I actually tried it on iOS.

(Problem)

Below is a screenshot of the actual application being created. The premise is that the screen background itself is blue, with a round image and text. The figure below is when the theme color is light (in case of dark, the background will be black)

(before dragging) image

(while dragging)

image

Steps to Reproduce

        <Grid Grid.Row="0" RowDefinitions="100,20" BackgroundColor="Transparent">
            <Grid.GestureRecognizers>
                <DragGestureRecognizer DragStartingCommand="{Binding DragCommand}"/>
            </Grid.GestureRecognizers>
            <Frame CornerRadius="40" 
                    HeightRequest="80"
                    WidthRequest="80"
                    HorizontalOptions="Center"
                    VerticalOptions="Center"
                    Padding="0"
                    IsClippedToBounds="True">
                <Image Source="./soccer_boy_brazil.png" Aspect="AspectFill"/>
            </Frame>
            <Label Grid.Row="1" Text="Brazil Boy" HorizontalTextAlignment="Center"/>
        </Grid>

More detailed information can be found sample app

Expected Behavior

I'd like to keep the background color transparent while dragging without changing it.

Actual Behavior

(while dragging)

image

Basic Information

Environment

Show/Hide Visual Studio info ``` === Visual Studio Community 2019 for Mac === Version 8.10.12 (build 16) Installation UUID: af7aac2f-9df6-4d1c-867d-74800db53288 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638) Package version: 612000140 === Mono Framework MDK === Runtime: Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit) Package version: 612000140 === Roslyn (Language Service) === 3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb === NuGet === バージョン: 5.9.0.7134 === .NET Core SDK === SDK: /usr/local/share/dotnet/sdk/6.0.100-rc.1.21463.6/Sdks SDK バージョン: 6.0.100-rc.1.21463.6 5.0.403 5.0.402 5.0.401 5.0.400 3.1.415 3.1.414 3.1.413 3.1.412 2.1.700 MSBuild SDK: /Applications/Visual Studio (Preview).app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks === .NET Core ランタイム === ランタイム: /usr/local/share/dotnet/dotnet ランタイム バージョン: 6.0.0-rc.1.21451.13 5.0.12 5.0.11 5.0.10 5.0.9 3.1.21 3.1.20 3.1.19 3.1.18 2.1.11 === .NET Core 3.1 SDK === SDK: 3.1.415 === Xamarin.Profiler === バージョン: 1.6.15.68 場所: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler === Updater === バージョン: 11 === Apple Developer Tools === Xcode 13.1 (19466) Build 13A1030d === Xamarin.Mac === Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version. === Xamarin.iOS === Version: 15.2.0.1 (Visual Studio Community) Hash: 8fd9e6289 Branch: xcode13.1 Build date: 2021-10-26 10:13:56-0400 === Xamarin Designer === Version: 16.11.0.39 Hash: cd672761d Branch: remotes/origin/d16-11 Build date: 2021-10-06 20:09:18 UTC === Xamarin.Android === バージョン: 12.0.0.3 (Visual Studio Community) コミット:xamarin-android/d16-11/f0e3c2d Android SDK: /Users/takeshi/Library/Developer/Xamarin/android-sdk-macosx サポートされている Android バージョン: 8.0 (API レベル 26) 8.1 (API レベル 27) SDK Tools のバージョン: 26.1.1 SDK プラットフォーム ツールのバージョン: 30.0.4 SDK ビルド ツールのバージョン: 30.0.2 ビルド情報: Mono: c633fe9 Java.Interop: xamarin/java.interop/d16-11@476bb5b ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.35.4@85460d3 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-11@87af37b === Eclipse Temurin JDK === Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home 1.8.0_302 Android Designer EPL のコードは以下から入手できます。 https://github.com/xamarin/AndroidDesigner.EPL === Android SDK Manager === Version: 16.10.0.13 Hash: 1b81df5 Branch: remotes/origin/d16-10 Build date: 2021-09-28 20:47:12 UTC === Android Device Manager === Version: 16.10.0.15 Hash: 89dcc0b Branch: remotes/origin/d16-10 Build date: 2021-09-28 20:47:30 UTC === Build Information === Release ID: 810120016 Git revision: e4f3f43ac50d8e0f83a71dbcb666bb1611a661d7 Build date: 2021-10-28 12:10:44-04 Build branch: release-8.10 === Operating System === Mac OS X 10.16.0 Darwin 20.6.0 Darwin Kernel Version 20.6.0 Wed Jun 23 00:26:31 PDT 2021 root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64 === Enabled user installed extensions === NuGet Package Management Extensions 0.27 ```

Screenshots

(Sample app screenshots)

iOS

image

image

image

image

Android

image

image

Reproduction Link

Xamarin.Forms_-DragGestureRecognizerSample

StackOverflow Link

https://stackoverflow.com/questions/69914556/draggesturerecognizer-in-xamarin-forms-sets-the-background-color-to-the-theme-co

faridseifi commented 2 years ago

I have the same issue in iOS while it works fine in Android.

faridseifi commented 2 years ago

Here are examples in my case for iOS before drag Screen Shot 2021-11-20 at 8 41 10 PM OS drag started Screen Shot 2021-11-20 at 8 41 37 PM drag moving Screen Shot 2021-11-20 at 8 41 47 PM