Custom StreamLayer Elements Guide

Add your own custom content as a menu item in the StreamLayer submenu on iOS.

The StreamLayer iOS SDK supports custom menu items, allowing you to add your own view controllers as units inside the StreamLayer Element. When the user selects your custom menu item, the SDK presents your view controller within its StreamLayer Element system.

Step-by-Step Guide

1. Create a Custom Menu Item

Define an SLRCustomMenuItem with your view controller, icon, and title:

private var customMenuItem: SLRCustomMenuItem = {
    let menuItem = SLRCustomMenuItem(viewController: MyCustomOverlayViewController())
    menuItem.iconImage = UIImage(named: "customMenuIcon")
    menuItem.title = "<YOUR TITLE>" 
    return menuItem
}()

2. Register the Menu Item

Add the custom menu item when creating a session:

StreamLayer.createSession(for: eventId, andAddMenuItems: [self.customMenuItem])

Notes

  • If you pass nil or an empty array, no custom items appear.
  • If menuItem.viewController is nil, the menu item will not appear.
  • If menuItem.iconImage is nil, the button appears without an icon.

Related