我有一个按钮,当按下该按钮时,会添加一个带有其他按钮的新子视图。我已经做到了
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget: @selector(newView)];
- (void)newView
{
UIView *newView = [[UIView alloc]initWithFrame:CGRectmake(0,0,100,100)];
[self.view addSubview:newView];
}
现在,当按下按钮时,将仅添加新视图。我想像在IB中一样以推播模式模式为新视图设置动画。如何以编程方式做到这一点?
最佳答案
尝试这样的事情。
- (void)newView
{
[self.view addSubview:newView]
newView.frame = // somewhere offscreen, in the direction you want it to appear from
[UIView animateWithDuration:10.0
animations:^{
newView.frame = // its final location
}];
}
关于ios - 以编程方式进行模式推送搜索-Objective-C,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16648588/