iOSReadText.cs 756 Bytes
Newer Older
Mattia's avatar
Mattia committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
using System;
using System.Threading.Tasks;
using SampleApp.DependencyServices;
using SampleApp.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: Dependency(typeof(iOSReadText))]
namespace SampleApp.iOS
{
    public class iOSReadText : IReadText
    {
        public iOSReadText()
        {
        }

        public void ReadText(Label t)
        {
            
            Device.StartTimer(TimeSpan.FromMilliseconds(100.0), () =>
            {
                Foundation.NSString ss = new Foundation.NSString(t.Text);
                UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, ss);
                return false; // runs again, or false to stop
            });
        }

    }
}