Pre-stream Setup | Co-Host Interaction | Audience Interaction | Live Room Management |
![]() | ![]() | ![]() | ![]() |
AnchorPrepareView component includes camera preview, audio effect settings, layout configuration, and other built-in features. Create and load the host streaming preparation view as shown below:import UIKitimport Snapkitimport TUILiveKitimport AtomicXCore// YourAnchorPrepareViewController represents the view controller for loading the host start pageclass YourAnchorPrepareViewController: UIViewController {private let roomId = "testLiveId"// Lazy load AnchorPrepareViewprivate lazy var prepareView: AnchorPrepareView = {// Pass roomId when initializing AnchorPrepareViewlet view = AnchorPrepareView(roomId: roomId)return view}()public override func viewDidLoad() {super.viewDidLoad()// Add prepareView to the viewview.addSubview(prepareView)prepareView.snp.makeConstraints { make inmake.edges.equalToSuperview()}}}
AnchorView component brings together audio/video streaming, audience co-hosting, interactive features, and live room management. Simply create and load AnchorView as shown below:import UIKitimport Snapkitimport TUILiveKitimport AtomicXCore// YourAnchorPrepareViewController represents the view controller for loading the host start pageclass YourAnchorViewController: UIViewController {// Core view componentprivate let coreView: LiveCoreView// Declare anchorView instanceprivate let anchorView: AnchorViewpublic init(liveInfo: LiveInfo, coreView: LiveCoreView? = nil, behavior: RoomBehavior = .createRoom) {if let coreView = coreView {self.coreView = coreView} else {self.coreView = LiveCoreView(viewType: .pushView)}// Instantiate the host start pageself.anchorView = AnchorView(liveInfo: liveInfo, coreView: self.coreView, behavior: behavior)super.init(nibName: nil, bundle: nil)}required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}public override func viewDidLoad() {super.viewDidLoad()// Add anchorView to the viewview.addSubview(anchorView)anchorView.snp.makeConstraints { make inmake.edges.equalToSuperview()}}}
Method | Description |
func onStartLiving() | Called when the host has successfully started streaming (room created/joined, streaming started). |
func onEndLiving(state: AnchorState) | Called when the host ends the stream. state includes live statistics: totalDuration (duration), totalViewers(audience count), totalMessageSent (live comments), totalGiftCoins (gift revenue), totalGiftUniqueSenders (gifters), totalLikesReceived (likes), liveEndedReason (end reason)—useful for displaying the live summary page. |
func onClickFloatWindow() | Called when the user clicks the floating window. |
import UIKitimport Snapkitimport TUILiveKitimport AtomicXCore// YourAnchorViewController handles loading the host start streaming pageclass YourAnchorViewController: UIViewController {// Core view componentprivate let coreView: LiveCoreViewprivate let liveID: String// AnchorView instanceprivate let anchorView: AnchorViewpublic init(liveInfo: LiveInfo, coreView: LiveCoreView? = nil, behavior: RoomBehavior = .createRoom) {if let coreView = coreView {self.coreView = coreView} else {self.coreView = LiveCoreView(viewType: .pushView)}self.liveID = liveInfo.liveID// Initialize the host start streaming pageself.anchorView = AnchorView(liveInfo: liveInfo, coreView: self.coreView, behavior: behavior)super.init(nibName: nil, bundle: nil)// Set delegate to listen for host page eventsanchorView.delegate = self}required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}public override func viewDidLoad() {super.viewDidLoad()// Add anchorView to the viewview.addSubview(anchorView)anchorView.snp.makeConstraints { make inmake.edges.equalToSuperview()}}}// Implement AnchorViewDelegate callbacksextension YourAnchorViewController: AnchorViewDelegate {// Host has successfully started streamingfunc onStartLiving() {}// Host ends the stream, display the SDK built-in live summary pagefunc onEndLiving(state: AnchorState) {let endInfo = AnchorEndStatisticsViewInfo(roomId: liveID,liveDuration: state.totalDuration,viewCount: state.totalViewers,messageCount: state.totalMessageSent,giftTotalCoins: state.totalGiftCoins,giftTotalUniqueSender: state.totalGiftUniqueSenders,likeTotalUniqueSender: state.totalLikesReceived,liveEndedReason: state.liveEndedReason)let anchorEndView = AnchorEndStatisticsView(endViewInfo: endInfo)anchorEndView.delegate = selfview.addSubview(anchorEndView)anchorEndView.snp.makeConstraints { make inmake.edges.equalToSuperview()}}// User clicked the floating windowfunc onClickFloatWindow() {FloatWindow.shared.showFloatWindow(controller: self, provider: self)}}// Implement FloatWindowProvider callbacksextension YourAnchorViewController: FloatWindowProvider {public func getRoomId() -> String {liveID}public func getOwnerId() -> String {LiveListStore.shared.state.value.currentLive.liveOwner.userID}public func getCoreView() -> AtomicXCore.LiveCoreView {coreView}public func relayoutCoreView() {anchorView.relayoutCoreView()}public func getIsLinking() -> Bool {let connectedSeats = CoGuestStore.create(liveID: liveID).state.value.connectedlet selfUserID = LoginStore.shared.state.value.loginUserInfo?.userID ?? ""return connectedSeats.contains(where: { $0.userID == selfUserID })}}
AnchorPrepareView component, as described in Step 3, to handle navigation from the preparation page to the host streaming page. Example code:import UIKitimport TUILiveKitimport AtomicXCore// Set delegate when initializing AnchorPrepareViewclass YourAnchorPrepareViewController: UIViewController {private lazy var prepareView: AnchorPrepareView = {let view = AnchorPrepareView(roomId: roomId)// Set delegateview.delegate = selfreturn view}()}// Implement AnchorPrepareViewDelegate callbackextension YourAnchorPrepareViewController : AnchorPrepareViewDelegate {// Handle start button click event// - state: PrepareState encapsulates camera, audio effects, and other settings for the host start page. You only need to configure as shown in the sample code below.public func onClickStartButton(state: PrepareState) {// Navigate to the host start page// Initialize live stream informationvar liveInfo = LiveInfo(seatTemplate: .videoDynamicGrid9Seats)// If you used Server APIs to pre-create the room, fill in the RoomId returned by the server here.liveInfo.liveID = roomIdliveInfo.liveName = state.roomNameliveInfo.coverURL = state.coverUrlliveInfo.isPublicVisible = state.privacyMode == .publicliveInfo.backgroundURL = state.coverUrl// Instantiate your host start view controllerlet anchorVC = YourAnchorViewController(liveInfo: liveInfo, coreView: prepareView.getCoreView())anchorVC.modalPresentationStyle = .fullScreen// Destroy the preparation page when going live: do not stack the streaming page on top of the preparation pageguard let presenter = presentingViewController else {present(anchorVC, animated: false)return}presenter.dismiss(animated: false) {presenter.present(anchorVC, animated: false)}}// Handle back button click eventpublic func onClickBackButton() {if let nav = navigationController {nav.popViewController(animated: true)} else {dismiss(animated: true)}}}

Layout | Dynamic Grid Layout | Floating Window Layout | Fixed Grid Layout | Fixed Floating Window Layout |
Template Value | .videoDynamicGrid9Seats | .videoDynamicFloat7Seats | .videoFixedGrid9Seats | .videoFixedFloat7Seats |
Description | Default layout. The grid size adjusts dynamically based on the number of co-hosts. | Co-hosts are shown in floating windows. | The number of co-hosts is fixed. Each guest occupies a dedicated grid cell. | The number of co-hosts is fixed. Guests appear in fixed floating windows. |
Preview | ![]() | ![]() | ![]() | ![]() |
prepareView created in Step 3 to hide the entire operation area or specific features on the preparation page.import UIKitimport Snapkitimport TUILiveKitimport AtomicXCore// YourAnchorPrepareViewController represents the view controller for loading the host start pageclass YourAnchorPrepareViewController: UIViewController {private let roomId = "testLiveId"private lazy var prepareView: AnchorPrepareView = {let view = AnchorPrepareView(roomId: roomId)view.delegate = selfreturn view}()public override func viewDidLoad() {super.viewDidLoad()// Add prepareView to the viewview.addSubview(prepareView)prepareView.snp.makeConstraints { make inmake.edges.equalToSuperview()}// Customize feature area - Example: Hide beauty featureprepareView.disableMenuBeauty(true)}}
API | Description |
disableFeatureMenu(true) | Hide the entire feature area |
disableMenuBeauty(true) | Hide the beauty button |
disableMenuAudioEffect(true) | Hide the audio effect button |
disableMenuSwitchCamera(true) | Hide the camera switch button |
AnchorView.AnchorView.
TUILiveKit.xcassets to manage UI image resources. Customize icons for your interface quickly using Xcode's graphical asset tools.
Feature | Description | Integration Guide |
Audience Viewing | Allow audience to join the host's live room and watch the stream, including audience co-hosting, live room info, online audience list, and live comments display. | |
Live Stream List | Show the live stream list interface and features, including live stream list and room info display. | |
Gift System | Configure custom gift assets, integrate billing, enable PK interactions, and more. |

フィードバック