我正在尝试将掩码应用于后端视图,但无法达到我的期望。我希望视图应该像在下面的图像中显示。 我尝试以自己的方式实现,但掩码视图也从底部出现。当我们立即点击iPad中的iCloud选项时,后端视图变为灰色,自定义视图从底部显示。我希望在我的应用程序中实现相同的功能。请帮我。提前谢谢。
答案 0 :(得分:1)
我强烈建议你使用这个漂亮而整洁的git代码
https://github.com/jmascia/KLCPopup
KLCPopup在使用动画,模糊,淡入淡出等实现模态视图方面做得非常好。
非常容易设置和使用,它只是
"选择你的观点"
"选择你想要的地方"
"如果你想要一些"
,添加效果"你去了#34;
玩得开心;)
答案 1 :(得分:0)
按照以下步骤来达到您的要求 -
1)创建一个BaseView&在BaseView的中心添加CustomView。
2)将BaseView的背景颜色设置为黑色,不透明度为50%。
3)将CustomView的实际转换保存在变量
中CGAffineTransform m_actualTransformOfCustomView =
m_customView.transform;
4)使用
将CustomView缩放到0.01,0.01self.m_customView.transform = CGAffineTransformScale(m_actualTransformOfCustomView, 0.01, 0.01);
4)使用[UIView amimateWithDuration:]
api将自定义视图的转换更改为原始 -
[UIView animateWithDuration:0.5f
delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
self.m_customView.transform = CGAffineTransformScale(m_actualTransformOfCustomView, 1.0, 1.0);
}
completion:^(BOOL finished)
{
}
];
}
答案 2 :(得分:0)
我自己的方式现在正常运作。这是代码片段。享受!
-(IBAction)show:(id)sender{
customView = [[UIView alloc] initWithFrame:self.view.frame]; // Mask View
customView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3f];
[self.view addSubview:customView];
// customConfigurationView // PopUp view
CGRect frameCustmVw = customConfigurationView.frame;
frameCustmVw.origin.y = self.view.frame.size.height;
frameCustmVw.origin.x = 134;
customConfigurationView.frame = frameCustmVw;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
frameCustmVw.origin.y = 200;
customConfigurationView.frame = frameCustmVw;
[self.view addSubview:customConfigurationView];
[UIView commitAnimations];
[txtClientID becomeFirstResponder];
}
-(IBAction)remove:(id)sender{
[customView removeFromSuperview]; // Remove mask view
CGRect CustmFrame = customConfigurationView.frame;
CustmFrame.origin.y = 200;//self.view.frame.size.height - customConfigurationView.frame.size.height;
customConfigurationView.frame = CustmFrame;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CustmFrame.origin.y = self.view.frame.size.height;
customConfigurationView.frame = CustmFrame;
[UIView commitAnimations];
}
答案 3 :(得分:0)
oky,关于设置应用程序如何做到这一点的答案,很简单......他们只是展示一个导航控制器,例如
只需创建一个视图控制器子类(我将其命名为TestViewController
)并将其大小设置为freeform
中的attribute inspector
,并将其框架的宽度和高度更改为所需的值,添加视图组件
它将以动画
显示宽度和高度为540 * 620的视图控制器这就是全部
- (IBAction)presentAction:(id)sender
{
TestViewController *testVc = [[TestViewController alloc]initWithNibName:@"TestViewController" bundle:nil];
UINavigationController *aNavController = [[UINavigationController alloc] initWithRootViewController:testVc];
aNavController.modalPresentationStyle = UIModalPresentationFormSheet;
aNavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:aNavController animated:YES completion:nil];
}