local text = ccui.Text:create(content, "font/sysfont.ttf", 18)
text:setPosition(pos) --设置位置
text:setColor(color) --设置颜色
text:setFontSize(size) --设置字体大小
text:setTextHorizontalAlignment(alignment or cc.TEXT_ALIGNMENT_LEFT) -设置字体水平方向 (左 中,右)
text:setTextVerticalAlignment(vlignment or cc.VERTICAL_TEXT_ALIGNMENT_TOP) --设置字体垂直方向 (上 中,下)
self.m_gameRuleDesc:ignoreContentAdaptWithSize(true) --设置字体 自定义尺寸 true 取消自定义 尺寸,false默认自定义尺寸
text:getVirtualRenderer():setWidth(170) --设置text的顶宽
local rule = ruleFrame:getChildByName("rule")
if ruleFrame:getChildByName("rule") == nil then
rule = ccui.Text:create(self.m_service:getGameDesc(), "font/sysfont.ttf", 20)
rule:getVirtualRenderer():setWidth(170)
rule:setName("rule")
rule:setAnchorPoint(cc.p(0,1.0))
ruleFrame:addChild(rule)
rule:setPosition(cc.p(15.33,85))
end
rule:setString(self.m_service:getGameDesc())
local size = rule:getContentSize()
if rule:getContentSize().height > 90 then
ruleFrame:setContentSize(ruleFrame:getContentSize().width,rule:getContentSize().height + 20)
rule:setPosition(cc.p(15.33,85 + rule:getContentSize().height + 20 - 90))
end