带有UIImage按钮和字幕的导航栏

时间:2019-06-28 16:17:33

标签: ios objective-c

我想重新创建类似下面的图像,它是带有UIImage按钮和字幕的导航栏。

enter image description here 我当前的代码如下所示

public class Application{  

    static void Main(string[] args){  
        //UIApplication.Main(args, null, "AppDelegate");  
        UIApplication.Main(args, "MyApplication", "AppDelegate");  
    }  

}  

//DELEGATE  
[Register("MyApplication")]  
public class MyApplication : UIApplication {  

    public override void SendEvent(UIEvent uievent) {  
        base.SendEvent(uievent);  
        var allTouches = uievent.AllTouches;  
        if (allTouches.Count > 0) {  
            var phase = ((UITouch)allTouches.AnyObject).Phase;  
            if (phase == UITouchPhase.Began || phase == UITouchPhase.Ended)  
                ResetIdleTimer();  
        }  
    }  

    NSTimer idleTimer;  
    void ResetIdleTimer() {  
        if (idleTimer != null) {  
            idleTimer.Invalidate();  
            idleTimer.Dispose();  
        }  

        idleTimer = NSTimer.CreateScheduledTimer(TimeSpan.FromMinutes(0.5), TimerExceeded);  
    }  

    void TimerExceeded(NSTimer obj) {  

        MvxiOSToastService toastService = new MvxiOSToastService();
        toastService.DisplayMessageAndDoSomething("You are going to be timed out.","Idle time exceeded.", RedirectToLogin);  

        Console.WriteLine("idle time exceeded");  
    }  

    void RedirectToLogin() {  

        var window = UIApplication.SharedApplication.KeyWindow;  
        var vc = window.RootViewController;  

        //ERROR HERE  
        var nextVC = new LoginView();   
        vc.ShowViewController(nextVC, this);  
        //----------
    }  
}  

有人可以帮我吗?

1 个答案:

答案 0 :(得分:-1)

在iOS中,这是通过通常在屏幕底部显示的标签栏控制器完成的,如果要在屏幕顶部显示,请使用工具栏。

看看calendar app of iPhone,它在右侧有3个按钮,这就是如果在导航栏中添加按钮的样子。

我更喜欢使用情节提要或XIB,然后在其中添加所有的barbutton项,并为其分配IBAction方法here's an example of how you can use storyboard for the same

工具栏中使用的按钮可以带有带标题的图像,以显示相同的外观和感觉。

希望有帮助。

相关问题