Freigeben über


Farbe für Eingabecursor unter iOS

Diese plattformspezifische iOS-Plattform legt die Cursorfarbe einer Entry auf eine angegebene Farbe fest. Sie wird in XAML genutzt, indem sie die bindungsfähige Eigenschaft Entry.CursorColor auf eine Color festlegt:

<ContentPage ...
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core">
    <StackLayout>
        <Entry ... ios:Entry.CursorColor="LimeGreen" />
    </StackLayout>
</ContentPage>

Alternativ kann sie mit der Fluent-API von C# genutzt werden:

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...

var entry = new Xamarin.Forms.Entry();
entry.On<iOS>().SetCursorColor(Color.LimeGreen);

Die Entry.On<iOS>-Methode gibt an, dass diese plattformspezifische Eigenschaft nur unter iOS ausgeführt wird. Die Entry.SetCursorColor-Methode im Namespace Xamarin.Forms.PlatformConfiguration.iOSSpecific legt die Cursorfarbe auf eine angegebene Color fest. Darüber hinaus kann die Entry.GetCursorColor-Methode zum Abrufen der aktuellen Cursorfarbe verwendet werden.

Das Ergebnis ist, dass die Cursorfarbe in einem Entry auf eine bestimmte Color festgelegt werden kann:

Farbe für Eingabecursor