【发布时间】:2015-05-20 15:41:57
【问题描述】:
我想更改启用自动布局功能的 UIButton 的大小(宽度、高度)。以下是关闭自动布局功能的代码。启用自动布局功能后,我应该做哪些更改才能使代码正常工作。
println("height : \(height)")
println("width : \(width)")
if (height == 460)
{
btn1.frame = CGRectMake(22, 66, 40, 40)
//btn1.sizeToFit()
//btn1.frame = CGRectMake(200, 200, 100, 100)
println("480")
self.view.addSubview(btn1)
}
else if (height == 548)
{
btn1.frame = CGRectMake(22, 66, 60, 60)
//btn1.frame.size.height = 65;
//CGRect frame = btn1.frame;
//btn1.frame.size.height = btn1.frame.size.height-20;
//btn1.frame = CGRectMake(200, 200, 100, 100)
println("548")
//btn1.sizeToFit()
//self.view.addSubview(btn1)
}
else
{
//btn1.sizeToFit()
btn1.frame = CGRectMake(22, 66, 75, 75)
//btn1.frame = CGRectMake(200, 200, 100, 100)
println("647")
self.view.addSubview(btn1)
}
【问题讨论】:
标签: iphone swift uibutton autolayout