我想在不使用removeFromSuperView和addSubview的情况下动态更改UIView的内容。代码是我想要做的事情的图像。
int screenWidth = [[UIScreen mainScreen] bounds].size.width;
int screenHeight = [[UIScreen mainScreen]bounds].size.height;
UIView *currentView = [[UIView alloc]initWithFrame:CGRectMake(0,0,screenWidth,screenHeight)];
UIView *nextView = [[UIView alloc]initWithFrame:CGRectMake(0,0,screenWidth,screenHeight)];
[self.view addSubview:currentView];
currentView = nextView;
//when this code run,appearing currentView swap nextView.
[self.view reload];
最佳答案
当然。如果您希望它看起来不错,请使用您想要的属性创建“结束” View 并使用静态 transition方法:+transitionFromView:toView:duration:options:completion:
.
这将根据需要删除和添加 View ,这样您就不必调用这些方法。否则,您可以使用-setHidden:
janusfidel 建议的方法,以隐藏您不想看到的 View 。
关于iphone - 我可以动态更改 UIView 的内容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13154729/