gpt4 book ai didi

ios - 在 UIButton 单击时显示像 PopUpView 一样的 UIView?

转载 作者:行者123 更新时间:2023-11-28 19:29:51 29 4
gpt4 key购买 nike

我有 UiView(PromoView),我想在 UIButton 的操作上打开 PromoView,同时在弹出 View 打开时设置背景模糊,当用户单击 View 中的任意位置时,PoPView 将被隐藏。这是我的代码..

-(IBAction)PromoCode_btn:(id)sender
{
_PromoView.hidden=NO;
_PromoView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.view.alpha=0.5;
_PromoView.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished){
}];
}

它只是用动画打开,帮我写代码...

最佳答案

viewDidLoad中添加UITapGestureRecognizer到 View

UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];

[_PromoView addGestureRecognizer:singleFingerTap];

//The event handling method
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer{
//Do animation here...

_PromoView.hidden = YES;

}

关于ios - 在 UIButton 单击时显示像 PopUpView 一样的 UIView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46539387/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com