2026/10/27 17:43:29
自定义教具与样式
适用于 Fastboard iOS 1.4.6。本页通过 Fastboard 公开的原生 SDK 对象配置教具插件。
在创建 FastRoom 前设置配置,入房成功后使用 fastRoom.room 和 fastRoom.whiteSDK。delegate 通过 fastRoom.commonDelegate、roomDelegate 设置,避免覆盖 Fastboard 内部代理。
Swift
let config = FastRoomConfiguration(appIdentifier: appIdentifier,
roomUUID: uuid, roomToken: roomToken, region: .CN, userUID: uid)
config.whiteSdkConfiguration.useMultiViews = true
config.whiteSdkConfiguration.enableAppliancePlugin = true
let pluginOptions = WhiteAppliancePluginOptions()
pluginOptions.extras = ["useBackgroundThread": true]
config.whiteRoomConfig.appliancePluginOptions = pluginOptions
let fastRoom = Fastboard.createFastRoom(withFastRoomConfig: config)
以下 Objective-C 示例也可用于原生调用:config 表示 FastRoomConfiguration.whiteSdkConfiguration,roomConfig 表示 whiteRoomConfig,room、whiteSDK 分别来自已入房 FastRoom 的同名属性。
先按插件介绍启用插件,在入房成功后提交当前用户的教具状态。
Objective-C
WhiteMemberState *state = [WhiteMemberState new];
state.currentApplianceName = AppliancePencil;
state.strokeColor = @[@32, @102, @255];
state.strokeWidth = @4;
state.strokeOpacity = @0.8;
[room setMemberState:state];
| 字段 | 用途 |
|---|---|
| currentApplianceName | Selector/Pencil/Shape/Text 等教具切换 |
| strokeColor / strokeWidth / strokeOpacity | RGB 颜色、粗细、线条透明度 |
| shapeType / fillColor / fillOpacity | 图形类型、填充颜色和透明度 |
| textColor / textSize | 文字颜色和字号 |
| pencilEraserSize | 局部橡皮尺寸 |
WhiteRoomConfig.appliancePluginOptions.extras 支持插件已开放的可序列化配置,例如 dottedStroke、longDottedStroke、normalStroke、textEditor、strokeWidth、pencilEraser、overwriteSelectorStyles。在入房前设置:
Objective-C
WhiteAppliancePluginOptions *options = [WhiteAppliancePluginOptions new];
options.extras = @{
@"useBackgroundThread": @YES,
@"normalStroke": @{ @"lineCap": @"round" },
@"dottedStroke": @{ @"lineCap": @"round", @"segment": @1, @"gap": @2 },
@"overwriteSelectorStyles": @{
@"highlightBox": @{ @"borderColor": @"#2066ff" },
@"highlightBoxPoint": @{ @"backgroundColor": @"#ffffff" }
}
};
roomConfig.appliancePluginOptions = options;
以上 Selector 样式作用于内嵌白板界面的选中框。应用可用 UIKit/SwiftUI 控制本端工具栏,并通过 setMemberState: 设置教具与样式;撤销、重做、复制、删除使用本端 WhiteRoom 的公开方法。
Auto Shape 可通过业务扩展模型传递,见Auto Shape。完整签名见客户端 API。