【发布时间】:2012-06-17 20:30:39
【问题描述】:
我想要一个带有图像和标题的 UIButton。我使用-setTitleEdgeInsets 显示文本。
但我不想通过反复试验来获得正确的位置,因为按钮的标题应该是动态的。我尝试确定 UIButtons titleLabel 对象的大小和位置,并使用以下代码设置与其对应的 titleEdgeInsets:
[myButton setTitleEdgeInsets:UIEdgeInsetsMake(myButton.center.y - (myButton.titleLabel.bounds.size.height / 2),
- (myButton.center.x - (myButton.titleLabel.bounds.size.width / 2)),
myButton.center.y + (myButton.titleLabel.bounds.size.height / 2),
myButton.center.x + (myButton.titleLabel.bounds.size.width / 2))];
我在这里遗漏或误用了什么吗?
在此先感谢您-朱利安
【问题讨论】:
标签: uiimageview uibutton uilabel title