Skip to content

如何使标题居中显示?

changsanjiang edited this page Sep 26, 2020 · 3 revisions

请按以下步骤操作:

  1. 禁止标题滚动:
    _player.defaultEdgeControlLayer.titleView.scrollEnabled = NO;
  1. 设置富文本标题:
    SJVideoPlayerURLAsset *asset = [[SJVideoPlayerURLAsset alloc] initWithURL:URL];
    _player.defaultEdgeControlLayer.titleView.scrollEnabled = NO;
    asset.attributedTitle = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol>  _Nonnull make) {
        make.append(@"视频的标题");
        make.textColor(UIColor.whiteColor);
        make.alignment(NSTextAlignmentCenter); // 使标题居中显示
    }];
    _player.URLAsset = asset; // 播放