richtext 用的是BBcode标签语言
后续可能要用,暂记,未测试
self.contentScrollview:removeAllChildren()
local richText = ccui.RichText:create();
richText:ignoreContentAdaptWithSize(false);
richText:setAnchorPoint({x = 0,y = 1});
self.contentScrollview:setAnchorPoint({x = 0,y = 1});
self.contentScrollview:addChild(richText);
self.richText[i] = richText
richText:setVisible(true)
richText:setContent(self.contentInfo[select]);
richText:setContentSize(self.contentScrollview:getContentSize().width,self.contentScrollview:getContentSize().height)
richText:formatText();
local curSize = richText:getVirtualRendererSize();
self.contentScrollview:getInnerContainer():setPosition(0,self.contentScrollview:getInnerContainerSize().height)
self.contentScrollview:setInnerContainerSize({width = curSize.width,height = curSize.height}) --设置滑动的区域
richText:setContentSize(curSize.width,curSize.height);
richText:setPosition(0,self.contentScrollview:getInnerContainerSize().height);
self.contentScrollview:forceDoLayout(); --刷新布局
self.contentScrollview:jumpToTop() --跳到最上面
richText:formatText();
local curSize = richText:getVirtualRendererSize();--配合使用获取富文本文字的实际高度
网友评论