logo
当前页

调整布局

音视频通话 UIKit 目前支持画中画(picture-in-picture)布局和宫格式(gallery)布局,每种布局都有自己的配置。 如需选择和配置布局,请在 ZegoUIKitPrebuiltCallConfig 中使用 layout 参数。

画中画布局

画中画布局支持配置 switchLargeOrSmallViewByClick,允许用户点击小视图以实现在大视图和小视图之间切换。默认为允许。

效果如下:

当摄像头关闭时显示我的视图当摄像头关闭时隐藏我的视图切换

以下是参考代码:

class ViewController: UIViewController {
    
    let selfUserID: String = "userID"
    let selfUserName: String = "userName"
    let yourAppID: UInt32 = YourAppID 
    let yourAppSign: String = YourAppSign
    let callID: String = "testCallID"
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    @IBAction func makeNewCall(_ sender: Any) {
        
        // 在此处修改自定义配置。
        let config: ZegoUIKitPrebuiltCallConfig = ZegoUIKitPrebuiltCallConfig.oneOnOneVideoCall()

        let layout: ZegoLayout = ZegoLayout()
        layout.mode = .pictureInPicture
        let pipConfig: ZegoLayoutPictureInPictureConfig = ZegoLayoutPictureInPictureConfig()
        pipConfig.switchLargeOrSmallViewByClick = true;
        layout.config = pipConfig
        config.layout = layout

        let callVC = ZegoUIKitPrebuiltCallVC.init(yourAppID, appSign: yourAppSign, userID: selfUserID, userName: selfUserName ?? "", callID: callID, config: config)
        callVC.modalPresentationStyle = .fullScreen
        self.present(callVC, animated: true, completion: nil)
    }
}

宫格式布局

宫格式布局支持的配置是:

  • addBorderRadiusAndSpacingBetweenView:在宫格式布局中,可以使用此选项添加边框圆角半径和视图之间的间距。true:启用(默认)。false:禁用。

效果如下:

添加边框圆角半径和间距不添加边框圆角半径和间距
class ViewController: UIViewController {
    
    let selfUserID: String = "userID"
    let selfUserName: String = "userName"
    let yourAppID: UInt32 = YourAppID
    let yourAppSign: String = YourAppSign
    let callID: String = "testCallID"
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    @IBAction func makeNewCall(_ sender: Any) {
        
        // 在此处修改自定义配置。
        let config: ZegoUIKitPrebuiltCallConfig = ZegoUIKitPrebuiltCallConfig.groupVideoCall()

        let layout: ZegoLayout = ZegoLayout()
        layout.mode = .gallery
        let layoutConfig: ZegoLayoutGalleryConfig = ZegoLayoutGalleryConfig()
        layoutConfig.addBorderRadiusAndSpacingBetweenView = false;
        layout.config = layoutConfig
        config.layout = layout

        let callVC = ZegoUIKitPrebuiltCallVC.init(yourAppID, appSign: yourAppSign, userID: selfUserID, userName: selfUserName ?? "", callID: callID, config: config)
        callVC.modalPresentationStyle = .fullScreen
        self.present(callVC, animated: true, completion: nil)
    }
}

Previous

添加自定义 UI 组件

Next

隐藏用户视图上的标签

当前页

返回到顶部