如何将掩码应用于后端视图?

Posted

技术标签:

【中文标题】如何将掩码应用于后端视图?【英文标题】:How to apply mask to backend view? 【发布时间】:2015-03-30 06:27:54 【问题描述】:

我正在尝试将掩码应用于后端视图,但无法达到我的期望。我希望视图应该如下图所示。 我尝试以自己的方式实现,但遮罩视图也从底部出现。当我们在 iPad 中单击 iCloud 选项时,后端视图立即变为灰色,并且自定义视图从底部出现。我希望在我的应用程序中实现相同的功能。请帮我。提前致谢。

【问题讨论】:

你尝试过/研究过什么?你的解决方案有什么问题? @Wain,感谢您的回复!我在下面添加了答案。 【参考方案1】:

我强烈建议你使用这个漂亮整洁的 git 代码

https://github.com/jmascia/KLCPopup

KLCPopup 在使用动画、模糊、淡入淡出等实现模态视图方面确实做得非常好。

非常容易设置和使用,真的很简单

"选择您的视图"

" 选择你想要的地方"

" 如果需要,请添加效果"

“给你”

玩得开心;)

【讨论】:

非常感谢!这是一篇非常好的文章。【参考方案2】:

按照以下步骤实现您的要求-

1) 创建一个 BaseView 并在 BaseView 的中心添加一个 CustomView。

2) 设置BaseView的背景颜色为黑色,不透明度为50%。

3) 将CustomView的实际变换保存在一个变量中

CGAffineTransform m_actualTransformOfCustomView = 
m_customView.transform;

4) 将 CustomView 缩放到小的 0.01 , 0.01 使用

self.m_customView.transform = CGAffineTransformScale(m_actualTransformOfCustomView, 0.01, 0.01);

4) 使用[UIView amimateWithDuration:] api将自定义view的transform改成原来的as-

[UIView animateWithDuration:0.5f
                          delay:0
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^
     
         self.m_customView.transform = CGAffineTransformScale(m_actualTransformOfCustomView, 1.0, 1.0);

     
                     completion:^(BOOL finished)
     

     
];

【讨论】:

【参考方案3】:

我自己的方式现在工作正常。这是代码sn-p。尽情享受吧!

-(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];

 

【讨论】:

【参考方案4】:

好的,我的回答是关于设置应用程序如何做到这一点,这很简单......他们只是展示了一个导航控制器,例如

例如,只需创建一个视图控制器子类(我将其命名为TestViewController)并将其大小设置为attribute inspector 中的freeform,并将其框架的宽度和高度更改为您需要的值并添加视图组件

它将显示宽度和高度为 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];

【讨论】:

以上是关于如何将掩码应用于后端视图?的主要内容,如果未能解决你的问题,请参考以下文章

[Web 前端] mockjs让前端开发独立于后端

mock.js-无需等待,让前端独立于后端进行开发

如何将交易从元掩码钱包发送到后端节点 js

markdown 适用于后端和前端开发人员的最受欢迎的Google Chrome扩展程序。

mock.js-无需等待,随机产生数据,让前端独立于后端进行开发

无法将掩码添加到输入