2013-11-21 40 views
1

我需要在运行时修改UIButton的宽度。具有此按钮的xib文件启用了自动布局。用aoutolayout以编程方式修改UIButton宽度

CGFloat delta = 40.0; 
      self.Button.frame = CGRectMake(self.Button.frame.origin.x - delta, 
                self.Button.frame.origin.y, 
                self.Button.frame.size.width + delta, 
                self.Button.frame.size.height 
                ); 

如何在autolayout上做到这一点?

+0

你试过了吗? – Undo

回答

1

创建指定宽度的约束的出口。当你想改变框架时,不要。更改约束。