如何交换2个UIButton的位置

时间:2015-11-26 10:40:13

标签: ios objective-c uibutton autolayout

我想在按下特定按钮时交换2 Autolayout的位置。这是我的代码。它们都受 CGRect tempFrame=_flightButton.frame; UIViewAutoresizing tempResize=_flightButton.autoresizingMask; [_flightButton setFrame:_contactButton.frame]; [_flightButton setAutoresizingMask:_contactButton.autoresizingMask]; [_contactButton setFrame:tempFrame]; [_contactButton setAutoresizingMask:tempResize];

的限制
NSArray *tempConstraints=_flightButton.constraints;
    [_flightButton removeConstraints:_flightButton.constraints];
    [_flightButton addConstraints:_contactButton.constraints];
    [_contactButton removeConstraints:_contactButton.constraints];
    [_contactButton addConstraints:tempConstraints];

也试过这个。交换约束。这不起作用

{{1}}

0 个答案:

没有答案