0
我想更改自動佈局功能所在的UIButton的大小(寬度,高度)。以下是自動佈局功能關閉時正常工作的代碼。自動佈局功能開啓時,我應該做些什麼改變代碼。更改iPhone屏幕大小的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)
}
檢查此問題http://stackoverflow.com/questions/30300015/modifying-constraints/30301168#30301168 –