Author Topic: [Irrelevant] How do I make a background sprite hug a UILabel?  (Read 2023 times)

Thurinus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
[Irrelevant] How do I make a background sprite hug a UILabel?
« on: October 31, 2013, 04:26:48 PM »
Using NGUI 2.5.0c

Hi all,

I'm trying to get a background sprite to hug a UILabel that can have a variable width up to a certain max width. I've been referencing the UITooltip code that resizes the background to the UILabel. The problem with this approach is that if I have a UILabel with a lineWidth set, the background will always enclose the full lineWidth regardless of the amount of text in the UILabel. Is there a way to make the background shrink to the text if the text takes up less space than the full line width?

Thanks!
« Last Edit: November 01, 2013, 07:53:52 PM by Thurinus »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile

Thurinus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: How do I make a background sprite hug a UILabel?
« Reply #2 on: November 01, 2013, 07:53:33 PM »
I failed to mention that circumstances beyond my control make upgrading practically impossible (team decided it was a great idea to add some custom modifications to the libraries). Regardless, sorry for wasting your time.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [Irrelevant] How do I make a background sprite hug a UILabel?
« Reply #3 on: November 01, 2013, 08:18:56 PM »
Pro version of NGUI would allow you to keep your modifications and still remain up to date. One of many advantages of having access to the original source code repository.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: [Irrelevant] How do I make a background sprite hug a UILabel?
« Reply #4 on: November 02, 2013, 02:58:20 PM »
Anchor it to the label.

Also, you can upgrade with custom changes, if you're careful and use your versioning diffs.