Skip to main content
Choose how participants are displayed during a call. The SDK provides multiple layout options to suit different use cases like team meetings, presentations, or one-on-one calls.

Available Layouts

LayoutDescriptionBest For
.tileGrid layout with equally-sized tiles for all participantsTeam meetings, group discussions
.spotlightLarge view for the other participant, small tile for yourselfOne-on-one calls, presentations, webinars
.sidebarMain speaker with participants in a sidebarInterviews, panel discussions

Set Initial Layout

Configure the layout when joining a session using SessionSettingsBuilder:
let sessionSettings = CometChatCalls.sessionSettingsBuilder
    .setLayout(.tile)
    .build()

CometChatCalls.joinSession(
    sessionID: sessionId,
    callSetting: sessionSettings,
    container: callViewContainer,
    onSuccess: { message in
        print("Joined with TILE layout")
    },
    onError: { error in
        print("Failed: \(error?.errorDescription ?? "")")
    }
)

Change Layout During Call

Switch layouts dynamically during an active call using setLayout():
// Switch to Spotlight layout
CallSession.shared.setLayout("SPOTLIGHT")

// Switch to Tile layout
CallSession.shared.setLayout("TILE")

// Switch to Sidebar layout
CallSession.shared.setLayout("SIDEBAR")
Each participant can choose their own layout independently. Changing your layout does not affect other participants.

Listen for Layout Changes

Monitor layout changes using LayoutListener:
class CallViewController: UIViewController, LayoutListener {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        CallSession.shared.addLayoutListener(self)
    }
    
    deinit {
        CallSession.shared.removeLayoutListener(self)
    }
    
    func onCallLayoutChanged(layoutType: LayoutType) {
        switch layoutType {
        case .tile:
            print("Switched to Tile layout")
        case .spotlight:
            print("Switched to Spotlight layout")
        case .sidebar:
            print("Switched to Sidebar layout")
        default:
            break
        }
        // Update layout toggle button icon
        updateLayoutIcon(layoutType)
    }

    func onParticipantListVisible() {}
    func onParticipantListHidden() {}
    func onPictureInPictureLayoutEnabled() {}
    func onPictureInPictureLayoutDisabled() {}
}

Hide Layout Toggle Button

To prevent users from changing the layout, hide the layout toggle button in the call UI:
let sessionSettings = CometChatCalls.sessionSettingsBuilder
    .setLayout(.spotlight)           // Fixed layout
    .hideChangeLayoutButton(true)    // Hide toggle button
    .build()