views:

170

answers:

1

Trying to put in FontLabel (http://github.com/zynga/FontLabel) into a UIButton. At first I wanted to set titlelabel. But it's restricting a setter to it so i can't just set the label to it.

Just wondering if anyone has an idea in doing this without using images to set my custom button.

A: 

You could extend the UILabel class through a category to add some functionality. The problem is that UIButton creates its own UILabel, and you can't override that (safely). So if you choose to use a UIButton, your only option for changing the label's behavior from that of a standard UILabel is to actually change the UILabel class (via categories).

Alternatively, you could write your own UIControl and mimic the functionality of UIButton. Then you can do whatever you want.

EDIT - If that FontLabel class extends from UILabel, it may be possible to extend UIButton and use method swizzling to force it to instantiate a FontLabel as its titleLabel. This is pretty extreme though, and I think you're much better off writing your own UIControl that mimics button behavior.

DougW