Welcome,
Guest
. Please
login
or
register
.
October 04, 2024, 10:36:37 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UILabel Resize Freely truncates content
« previous
next »
Print
Pages: [
1
]
Author
Topic: UILabel Resize Freely truncates content (Read 3028 times)
Aurigan
Newbie
Thank You
-Given: 2
-Receive: 0
Posts: 21
UILabel Resize Freely truncates content
«
on:
August 17, 2017, 11:06:54 AM »
A UILabel with 'resize freely' overflow option AND a 'max width' set will truncate content after that max width is hit.
What would be the easiest way to change UILabel 'resize freely' overflow behavior to shrink content once that max width was hit?
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UILabel Resize Freely truncates content
«
Reply #1 on:
August 21, 2017, 06:28:33 PM »
Turn off resize freely, change it to shrink content -- and set the label's width/height to what it should be.
Logged
Aurigan
Newbie
Thank You
-Given: 2
-Receive: 0
Posts: 21
Re: UILabel Resize Freely truncates content
«
Reply #2 on:
August 24, 2017, 04:21:11 AM »
Hi Aren, thanks for the reply ... the issue is that I need the resize freely behavior - I want to have a label centered but with an icon anchored to the labels right. I guess the alternative hack would be to calc the content width and adjust the icon position in code but would prefer to have a code-free solution to something this standard!
What would your recommendation be for taking this on?
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UILabel Resize Freely truncates content
«
Reply #3 on:
August 25, 2017, 12:43:54 AM »
You can simply set the label's pivot point to the right side, then any child you add to that label will be automatically relative to that side, no anchoring needed.
Edit: I think I see what you're asking. Lemme think about it.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UILabel Resize Freely truncates content
«
Reply #4 on:
August 25, 2017, 01:02:55 AM »
Turns out this is easier than I thought. Go to UILabel, around line ~1400-1430
else
if
(
mOverflow
==
Overflow
.
ResizeFreely
)
{
mCalculatedSize
=
NGUIText
.
CalculatePrintedSize
(
mProcessedText
)
;
Add the !fits check like so:
else
if
(
mOverflow
==
Overflow
.
ResizeFreely
)
{
mCalculatedSize
=
NGUIText
.
CalculatePrintedSize
(
mProcessedText
)
;
if
(
!
fits
&&
mOverflowWidth
!=
0
)
{
if
(
--
ps
>
1
)
continue
;
else
break
;
}
Logged
Aurigan
Newbie
Thank You
-Given: 2
-Receive: 0
Posts: 21
Re: UILabel Resize Freely truncates content
«
Reply #5 on:
August 25, 2017, 04:13:44 AM »
Perfect! Thank you so much
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UILabel Resize Freely truncates content