how do I restrict UIButton title text from spilling over
New to posting here but got many really useful bits of help already.
I am shoving some text into a UIButton title ( UIButton setTitle: forState: ) I want only the first bit of the text to be displayed (ie only amount that fits). Currently, I am getting extra text spilling over into the view.
Is there any easy way to help stop the text from overflowing or do I have to implement my own word wrap algorithm to micromanage the amount of text I set t开发者_开发技巧he Title to?
Can't you set a maximum number of lines to the associated titleLabel
?
iPhone SDK already implemented the algorithm and there are a number of options. There is a lineBreakMode property which you can use. You can use UILineBreakModeTailTruncation as the value. However, this property is Deprecated in iOS 3.0. You need to use titleLabel in OS 3.0
精彩评论