gpt4 book ai didi

ios - 如何通过单击按钮删除按钮占用的空间

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:02:11 25 4
gpt4 key购买 nike

我是 iOS 新手。我想知道如何删除按钮占用的空间而不是隐藏按钮。

first image

首先我有 3 个按钮。点击button 2后我想去掉button 2占用的空间,改变button 3的位置

final image

最佳答案

为了完成您在图片中所解释的操作,您可以像这样编写 button2 操作方法

-(IBAction)btn2Action:(UIButton *)sender
{
button2.hidden = TRUE;
// Change y value (if you have all three buttons in vertical) of button 3 Frame Like:
CGRect btn3Frame = button3.frame;
btn3Frame.origin.y = button2.frame.origin.y;
button3.frame = btn3Frame;


// Change x value (if you have all three buttons in Horizontal) of button 3 Frame Like:
CGRect button3Frame = button3.frame;
button3Frame.origin.x = button2.frame.origin.x;
button3.frame = button3Frame;
}

关于ios - 如何通过单击按钮删除按钮占用的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41346339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com