开发者

When changing a UIButton's label, how do I prevent it from being shortened using '...'?

开发者 https://www.devze.com 2023-01-20 03:52 出处:网络
I\'m working on an iPhone app, and one of the buttons is supposed to have a text label on it that changes.When I set the text label programatically as seen below, it\'s shortened using \'...\' instead

I'm working on an iPhone app, and one of the buttons is supposed to have a text label on it that changes. When I set the text label programatically as seen below, it's shortened using '...' instead of displaying the full label -- even though there is ple开发者_JS百科nty of room for it on the button.

self.accuracyButton.titleLabel.text=@"User defined location";

I suspect this may be related by the way it 'resets' to the XIB defined 'accuracy' label whenever I try to click it, but I'm not sure how to fix it or what is going on.


please try

[button setTitle:@"foo" forState:UIControlStateNormal];

Yesterday I had the same issue, the button showed the three dots, even if there was enough room.
Using setTitle:forState: instead of setting the property displayed the text correctly


You can change the amount of padding around the label by using this:

@property(nonatomic) UIEdgeInsets titleEdgeInsets


Not sure why it cuts off, but might I suggest simply using a UILabel over the top of the button? That allows much more refined control of the label boundary and size.

0

精彩评论

暂无评论...
验证码 换一张
取 消