pmor
pmor

Reputation: 6277

How to properly align UIButton label text with fixed image

What is the most correct (logical, rational, elegant, understandable, right) way to align text label in the UIButton same way as shown in picture? Please note that text field changes in runtime dynamically. Thanks.

enter image description here

Upvotes: 1

Views: 129

Answers (1)

Kaveh Vejdani
Kaveh Vejdani

Reputation: 224

  1. Make your button of "custom" type.

  2. Init your UIImageView with frame (0,0,80,buttonHeight) then add as subview to your button.

  3. Init your text label with frame (100,0,buttonWidth-100,buttonHeight) then add as subview to your button.

Upvotes: 1

Related Questions