tombenner / nui

Style iOS apps with a stylesheet, similar to CSS
MIT License
3.76k stars 461 forks source link

UIButton not redrawn if its title changes #157

Open mflint opened 11 years ago

mflint commented 11 years ago

Summary

If the title of a button changes (which causes the size of the button to change) then the NUI style is not repainted.

Example 1

image

Example 2

image

What I've tried...

I tried to use KVO to watch for changes to the button's "self.titleLabel.text" property, but didn't get very far.

Another option would be to subclass UIButton and override "setTitle:forState:", but meh, subclassing :-/

So I'm stuck. @tombenner I'm happy to code and test any ideas you might have... I'm starting to think there's an easy solution I'm missing :-)

JoshJones57 commented 10 years ago

The shape containing the gradient "background-color-top/background-color-bottom" does not resize when the button does. Use the normal "background-color" and it will resize.

phatmann commented 10 years ago

We need additional code that resizes the gradient layer when the button size changes. We would need to use KVO to catch bounds changes, since we cannot subclass layoutSubviews or setBounds from a category. @JoshJones57, care to take a shot at this change?

mflint commented 10 years ago

@phatmann @JoshJones57 Hey, I'd forgotten I'd raised this issue.

I did a workaround for this, for when I'm targetting iOS6 only. I'll be dropping iOS6 support soon, so I won't need a fix for this.

If I'm the only person affected by this issue, I'd suggest closing with "Won't Fix". (But thank-you both for taking the time to respond!)