Label与ScrollView

来源:互联网 发布:站群软件 编辑:程序博客网 时间:2024/05/18 01:33
-- 初始化界面并绑定有用节点function EscortRuleDialog:__initViewAndBindNode()    local layout = UI.nodeFromCSB( Res.FileNames.res_ui_caravan_new_caravan_explain_csb, self )    layout:setPosition( VisibleRect:center() )    self:addChild( layout )    -- 获取help表    local helpDict = Dict.HelpList[self.initType]        -- 设置标题    UI.setString( self.lbl_title, helpDict.title )        -- 配置数据    local nodeSize = cc.size( 520, 29 )    local rowList = {}     local totalHeight = 0        -- 初始化配置数据    local strList = LuaUtils.Split2( helpDict.content, "#" )        -- 初始化滚动视图    UI.fixScrollView( self.scr_bg )    self.scr_bg:setContentSize( cc.size( nodeSize.width, nodeSize.height * 9 ) )    -- 初始化界面    local addUpHeight = 0    local offset = 30    local size = #strList    for i=size, 1, -1 do        local label = cc.Label:createWithTTF( T(strList[i]), Res.FileNames.res_font_arts_ttf, 20 )        label:setTextColor( cc.c3b( 12, 219, 244 ) )        label:setMaxLineWidth( nodeSize.width - offset )        label:setAnchorPoint( 0 , 0 )        label:setPosition( cc.p( offset , addUpHeight ) )        self.scr_bg:addChild( label )        addUpHeight = addUpHeight + label:getContentSize().height        local symbol = cc.Label:createWithTTF( "◆", Res.FileNames.res_font_arts_ttf, 20 )        symbol:setTextColor( cc.c3b( 12, 219, 244 ) )        symbol:setAnchorPoint( 0 , 0 )        label:addChild( symbol )        symbol:setPosition( cc.p( -offset , label:getContentSize().height - symbol:getContentSize().height ) )    end    local totalHeight = addUpHeight    if  totalHeight <= nodeSize.height * 9 then        local labels = self.scr_bg:getChildren()        for i, label in ipairs( labels ) do            label:setPositionY( label:getPositionY() + (nodeSize.height * 9 - totalHeight) )        end        totalHeight = nodeSize.height * 9    end    self.scr_bg:setInnerContainerSize( cc.size( nodeSize.width, totalHeight ) )    UI.onClick( self.btn_close, EscortRuleDialog.closeCallback, self )    UI.changeBtnSize( self.btn_close, 2, 2 )end

0 0
原创粉丝点击