matt
matt

Reputation: 1

Custom UIButton in Objective-C

i want a view with some button, each button must have an image on the left, e bold title and under this, details in italic, is possible make this?

The only (stupid) way i've found is put 2 label over the button, is there any other way?

Thanks for any reply.

Upvotes: 0

Views: 833

Answers (3)

tc.
tc.

Reputation: 33592

The cleanest way to have custom positioning of the image and label is to subclass UIButton and override -titleRectForContentRect: and -imageRectForContentRect:. Of course, UIButtons only have one label by default, so you'll need to add a second label (e.g. in -initWithFrame:/-initWithCoder:) and lay it out in -layoutSubviews

Upvotes: 1

Nick Weaver
Nick Weaver

Reputation: 47231

If the title and details are of dynamic nature you'll have to make your own subclass of UIButton and override the drawRect method.

Upvotes: 0

David
David

Reputation: 14404

You need to subclass a UIButton and in the – drawRect: method, do your custom drawing. You can pretty much draw whatever you like in it.

Upvotes: 0

Related Questions