Pre-stream Setup | Co-Host Interaction | Audience Interaction | Live Room Management |
![]() | ![]() | ![]() | ![]() |
TUILiveKit trial version or activate the paid version.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"// 2. Lazy load AnchorPrepareViewprivate lazy var prepareView: AnchorPrepareView = {// 3. Pass roomId when initializing AnchorPrepareViewlet view = AnchorPrepareView(roomId: roomId)return view}()public override func viewDidLoad() {super.viewDidLoad()// 4. 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// 1. 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)}// 3. 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()// 4. Add anchorView to the viewview.addSubview(anchorView)anchorView.snp.makeConstraints { make inmake.edges.equalToSuperview()}}}
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// 1. Set delegate when initializing AnchorPrepareViewclass YourAnchorPrepareViewController: UIViewController {private lazy var prepareView: AnchorPrepareView = {let view = AnchorPrepareView(roomId: roomId)// Set delegateview.delegate = selfreturn view}()}// 2. 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) {// 4. Navigate to the host start page// 4.1. 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// 4.2. Instantiate your host start view controllerlet anchorVC = YourAnchorViewController(liveInfo: liveInfo, coreView: prepareView.getCoreView())anchorVC.modalPresentationStyle = .fullScreen// 4.3. Navigate to your host start view controllerpresent(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()// 1. Add prepareView to the viewview.addSubview(prepareView)prepareView.snp.makeConstraints { make inmake.edges.equalToSuperview()}// 2. 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. |

Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan