diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 9c5a5650c9..90772d2fa7 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -648,8 +648,8 @@ protected: bool multilineTextWrapByChar(); bool multilineTextWrapByWord(); - bool multilineTextWrap(std::function lambda); - void shrinkLabelToContentSize(std::function lambda); + bool multilineTextWrap(const std::function& lambda); + void shrinkLabelToContentSize(const std::function& lambda); bool isHorizontalClamp(); bool isVerticalClamp(); float getRenderingFontSize()const; diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 34d265d14f..7228d2d29f 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -130,7 +130,7 @@ void Label::updateBMFontScale() } } -bool Label::multilineTextWrap(std::function nextTokenLen) +bool Label::multilineTextWrap(const std::function& nextTokenLen) { int textLen = getStringLength(); int lineIndex = 0; @@ -270,12 +270,12 @@ bool Label::multilineTextWrap(std::function lambda) +void Label::shrinkLabelToContentSize(const std::function& lambda) { float fontSize = this->getRenderingFontSize();