Reputation: 498
I have a timer on the navigation bar which runs after a button click, the timer is working on android but on iOS my timer is not updating.
Device.StartTimer(TimeSpan.FromSeconds(1), () =>
{
if (cts.IsCancellationRequested)
{
return false;
}
else
{
Device.BeginInvokeOnMainThread(() =>
{
TimeSpan _TimeSpan = DateTime.Now - startAt;
ToolbarTimer.Text = _TimeSpan.ToString(@"hh\:mm\:ss");
});
return true;
}
});
Upvotes: 0
Views: 61
Reputation: 569
For custom Navigationbar you can easily use TitleView (Shell or Naviagtion)
Try something like this:
<Shell.TitleView>
<Grid VerticalOptions="Center"
HorizontalOptions="Center">
<StackLayout Orientation="Horizontal"
HorizontalOptions="Center">
<Label Text="{Binding Title}"
FontSize="20"
TextColor="White"
VerticalTextAlignment="Center"
HorizontalOptions="Center" />
<Label Text="{Binding Timer}"
FontSize="20"
TextColor="White"
VerticalTextAlignment="Center"
HorizontalOptions="Center" />
</StackLayout>
</Grid>
</Shell.TitleView>
Upvotes: 1