- (void)appletDidTakeScreenshot:(TMFMiniAppInfo *)appletInfo atPagePath:(NSString *)pagePath;
- (void)applet:(TMFMiniAppInfo *)appletInfo screenCaptureStatusChanged:(BOOL)isCapture atPagePath:(NSString *)pagePath;
- (nullable UIView *)appletCustomizeWatermarkView:(TMFMiniAppInfo *)appletInfo
@interface MiniAppDemoSDKDelegateImpl : NSObject <TMFMiniAppSDKDelegate>+ (instancetype)sharedInstance;// 当前已挂载水印的弱引用。水印由其父视图强引用。@property (nonatomic, weak, nullable) UIView *watermarkView;// 当前是否显示水印@property (nonatomic, assign) BOOL shouldShowWatermark;@end
- (void)applet:(TMFMiniAppInfo *)appletInfo screenCaptureStatusChanged:(BOOL)isCapture atPagePath:(NSString *)pagePath {// 确保已经挂载到页面上的 watermarkView 的状态能被修改dispatch_block_t updateWatermark = ^{self.shouldShowWatermark = isCapture;self.watermarkView.hidden = !isCapture;};if ([NSThread isMainThread]) {updateWatermark();} else {dispatch_async(dispatch_get_main_queue(), updateWatermark);}}
/// 水印 View:默认隐藏,仅在录屏时由 screenCaptureStatusChanged: 显示- (nullable UIView *)appletCustomizeWatermarkView:(TMFMiniAppInfo *)appletInfo {// 该方法可能多次调用,移除当前示例此前创建的水印。[self.watermarkView removeFromSuperview];// 防止在录屏已经开始后才进入页面时,初始状态不正确。self.shouldShowWatermark = UIScreen.mainScreen.isCaptured;UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 190, 32)];container.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.45];container.layer.cornerRadius = 6;container.layer.masksToBounds = YES;container.userInteractionEnabled = NO;container.hidden = !self.shouldShowWatermark;UILabel *watermark = [[UILabel alloc] initWithFrame:container.bounds];watermark.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;watermark.text = @"TCMPP SDK Demo";watermark.textColor = [UIColor whiteColor];watermark.textAlignment = NSTextAlignmentCenter;watermark.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];[container addSubview:watermark];self.watermarkView = container;return container;}

文档反馈