开发者

UILabel Dynamic height problem

开发者 https://www.devze.com 2023-03-18 19:38 出处:网络
I have one UILabel and one button under the label. Height of the label is dynamic. I use this: [label sizeToFit]; But开发者_StackOverflow中文版 when the size of the label raise, it wrap the button. Ho

I have one UILabel and one button under the label. Height of the label is dynamic. I use this: [label sizeToFit]; But开发者_StackOverflow中文版 when the size of the label raise, it wrap the button. How can I rearrange the view ? Thanks in advance


How about something like this:

[label sizeToFit];
btn.frame = label.frame;

Thereby setting your button to the same size as the label... or manually adding some padding like this:

[label sizeToFit];
btn.frame = CGRectMake(label.frame.origin.x - 10, label.frame.origin.y - 10, label.frame.size.width + 20, label.frame.size.height + 20);
0

精彩评论

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

关注公众号