我有一个按钮,我想在它的点击事件中插入一个 UIView
。我知道如何插入 UIView
但是我无法插入/移动它下面的其他 UIView
以便我可以容纳添加的 UIView
.
我已经看过这个link但它不符合我的目的
有什么建议吗?
最佳答案
在按钮的方法中创建新 View 并将其添加为 subview 。将 frame.origin.x
设置为 0 减去 View 的宽度(如果您希望它从左侧推送),使其不可见,并将该值更改为您希望它位于内部的位置[UIView animateWithDuration:animations:]
。
[UIView animateWithDuration:1.0 animations:^(void){
[newView setFrame:({
CGRect frame = newView.frame;
frame.origin.x = 150; // If you want it to start at x = 150
frame;
})];
// If you want to move other views too, just add them in this block
}];
如果您不明白我正在做什么来设置框架,请查看此 post 中的第一个提示.
关于ios - 插入新的 uiview 时如何移动/推送其他 uiview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21187546/