iphone - How to override -drawrect in UIButton subclass? -


Hi I need to write some text on a custom button, so I subclassed UIButton - in the translation, the text I want I write. The problem is that the text ends under the button. After writing my text, UIButton's drawover moves forward and pulls me up.

I am not even calling [SuperDecor:], even though I was hoping to call it before making my call. It seems that the UIButton drawpass would be hesitant.

Any thoughts? Thank you.

As others have said, you do not need the UIButton subclass - in fact this is the best Is not too complicated as UIButton (as you found). You have three options:

  • Leave the button title blank and in the desired position, add a new text field to the button.
  • If you are using the 3.0 label property of the label, though the label itself is read only its properties (including the frame).
  • Sub-class UIControl UIControl is a UIView so that you can add other views - text and images and it is UIView that applies the action message behavior ( addTarget: action: forControlEvents: ) Does. UIButton implements statefulness above this

If you do not need things like UIButton's setTitle: forState: and related functionality but you have many of these controls I will use the third option, otherwise if you are on 3.0 then use the first (or second).


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -