Forum Xamarin.iOS

Update Status Bar Menu title

DanBolDanBol USMember ✭✭

I am trying to figure out how to update the Status bar menu title property from a timer type item.

This is what I have tried so far without success.

`

NSStatusItem _item;

    public AppDelegate()
    {
    }

    public override void DidFinishLaunching(NSNotification notification)
    {

        NSStatusBar _statusBar = NSStatusBar.SystemStatusBar;


        Random _rand = new Random();

        _item = _statusBar.CreateStatusItem(NSStatusItemLength.Variable);
        _item.Title = $"Text {_rand.Next(1, 100).ToString()}";


        Timer _timer = new Timer(2000);
        _timer.Elapsed += ATimer_Elapsed;
        _timer.Start();
    }

    void ATimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
        _item.Title = $" NEW Text";

    }

`

I have used the Action on the menu item, but I do not want it to be a event based item.

Tagged:

Best Answers

  • DanBolDanBol USMember ✭✭
    Accepted Answer

    Thank you ChrisHamons. Made perfect sense after you explained it.

Answers

  • DanBolDanBol USMember ✭✭
    Accepted Answer

    Thank you ChrisHamons. Made perfect sense after you explained it.

Sign In or Register to comment.