--- -- ================================================================ -- 文件名: NoticeTextView.lua -- 描述: 哀悼日活动 -- 版权: Copyright © 2016-2019 公司名称 版权所有 -- 作者: Administrator -- 创建日期: 2020-04-03 -- 更新日期: 2020-04-03 -- 备注: -- ================================================================ -- local NoticeTextView = class("NoticeTextView", cc.UIView); function NoticeTextView:ctor(notice,endCallback) NoticeTextView.super.ctor(self) if notice then self.notice = string.split(notice,"\n") end self.endCallback = endCallback end --- -- 进入界面 -- function NoticeTextView:onEnter() self:loadUI(); self:initViews(); self:initEvents(); end --- -- 加载UI布局 -- function NoticeTextView:loadUI() self.ui = loadUI("res/ui/ui_dating/ui_notice_aidaori.ui"); self:addChild(self.ui); end --- -- 初始化界面 -- function NoticeTextView:initViews() self.ui.Items.ScrollView:hideAllBar() self.ui.Items.ScrollView:getInnerContainer():setAutoSize(true) self.ui.Items.Layout_content:setVisible(false) for k,v in ipairs(self.notice) do if k == 1 then self.ui.Items.Text:setText(v) else local content = self.ui.Items.Layout_content:getCopied() content.Items = getUIItems(content) content.Items.Text_1:setText(v) self.ui.Items.ScrollView:addChild(content) content:requestDoLayout() content:doLayout() end end self.ui.Items.ScrollView:requestDoLayout() self.ui.Items.ScrollView:doLayout() self.ui.Items.ScrollView:jumpToTopOnSizeChanged() self.ui.Items.Button_Confirm:registerClick(handler(self, self.onBtnConfirmClicked)); end --- -- 初始化自定义事件 -- function NoticeTextView:initEvents() end function NoticeTextView:onBtnConfirmClicked() if self.endCallback and type(self.endCallback) == "function" then self.endCallback() end end return NoticeTextView;