﻿## UIKit 剩下的常用 API

### UIKit.Root.SetResolution

参数定义如下：

![image.png](https://file.liangxiegame.com/bac63766-0f9a-4d9c-92fd-cb6b90324262.png)

对应 UIRoot 上的 Canvas Scaler 如下:

![image.png](https://file.liangxiegame.com/bc2c2122-c559-48bf-8b2f-ea4609826493.png)

大部分项目，用这个 API 做屏幕适配足够了。

### UIKit.Root.Camera

获取 UIRoot 的摄像机。

```csharp
var uiCamera = UIKit.Root.Camera;
```

### UIKit.Stack.Push、UIPanel.Back（Pop）

有的时候，UI 需要实现一个 UI 界面的堆栈，以便于支持返回上一页这样的操作。

这个时候就可以用 Push 和 UIPanel.Back 实现。

示例代码:

```csharp
UIKit.Stack.Push(this); // this 是 Panel
// UIHomePanel 需要确保是打开的状态，如果不打开会报错。
UIKit.Stack.Push<UIHomePanel>();
            
this.Back(); // 弹出 UIHomePanel
this.Back(); // 弹出 this
```

非常简单。

本文由 QFramework 教程年会员赞助，地址：[https://www.gamepixedu.com/goods/show/55](https://www.gamepixedu.com/goods/show/55)

* QFramework 主页：[qframework.cn](https://qframework.cn)
* QFramework 交流群: 541745166
* QFramework Github 地址: <https://github.com/liangxiegame/qframework>
* QFramework Gitee 地址：<https://gitee.com/liangxiegame/QFramework>