【发布时间】:2015-06-26 12:18:26
【问题描述】:
我对 AutoLayout 有点陌生。我已经知道有关此 autoLayout 的大量问题和教程,但我还没有找到我的解决方案。所以提前感谢您的帮助。
我的要求是什么?
我必须制作 UIView,它会在从屏幕底部按下带有动画的按钮后出现在屏幕上。(就像键盘一样)。我已经使用 autoLayout 在 xib 文件中制作了这个 UIView。到目前为止,我已经完成了这个。
在 ViewDidLoad 中:
//Loading custom UIView
containerView = [[SharingPickerView alloc] init];
[containerView loadingMenus:pickerData];
[self.view addSubview:containerView];
在这个视图中它包含(滚动视图,然后是页面控制器,然后是取消按钮)
在 ViewWillLayoutSubviews 中:
-(void)viewWillLayoutSubviews{
[super viewWillLayoutSubviews];
//Changing the frame of view to bottom side of the screen so that we can animate it later from bottom to top later.
containerView.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, containerView.frame.size.height);
[containerView setBackgroundColor:[[UIColor colorWithRed:231.0/255.0f green:231.0/255.0f blue:231.0/255.0f alpha:1.0f] colorWithAlphaComponent:0.3]];
}
现在正在新闻中制作动画。
-(void)sharePickerView{
[UIView animateWithDuration:1 animations:^(){
containerView.frame = CGRectMake(0,self.view.frame.size.height-containerView.frame.size.height, self.view.frame.size.width, containerView.frame.size.width);
} completion:^(BOOL isFinished){
NSLog(@"Animation Finish");
}];
}
在这里,我正在重新构建视图以显示该动画,但某些底部部分(该视图的取消按钮)未显示在 iPhone 6 模拟器中,但它完美地显示了 iPhone 5s 设备。
问候 埃蒙。
【问题讨论】:
-
这是一个关于如何轻松制作静态自动布局动画的教程youtube.com/watch?v=8KVKXlh6sKI
标签: ios objective-c iphone autolayout nslayoutconstraint